当前位置:网站首页>Count the running time of PHP program and set the maximum running time of PHP
Count the running time of PHP program and set the maximum running time of PHP
2022-07-04 14:24:00 【Gegwu MMQ!!】
"; $starttime = explode(" ",$pagestartime); $endtime = explode(" ",$pageendtime); $totaltime = $endtime[0]-$starttime[0]+$endtime[1]-$starttime[1]; $timecost = sprintf("%s",$totaltime); echo " Page runtime : $timecost second "; ?>
Generally speaking , default PHP The maximum running time of the program is 30s, If your program runs beyond this time limit , Then there will be something similar Maximum execution time of 30 seconds exceeded The error of .
There are several solutions :
First, check whether you are doing something stupid , It consumes a lot of CPU Resources and time , If you really need the program to run for a long time to get results , Then you can.
1> stay php.ini Increase the running time :
max_execution_time=300
1.
2> stay PHP Add the following code to the file
ini_set(‘max_execution_time’, 300); //300 seconds = 5 minutes
1.
3> Use .htaccess File to increase running time :
Other common configuration references :
If your environment is wordpress, Then please config.php in , add to :
define(‘WP_MEMORY_LIMIT’, ‘128M’);
1.
If you use other frameworks , You can modify
ini_set(‘memory_limit’, ‘128M’);
By default , php.ini The maximum execution time configured in is 30 second , This is from php.ini Medium max_execution_time Variable . If we have a job that takes a lot of time , For example, send a lot of emails , Or a huge statistical analysis of data . Even if the task is not completed , The server will 30 Seconds later, forcibly abort the executing program .
1, Two ways to modify the maximum execution time
(1) Directly modifying php.ini in max_execution_time The numerical .
(2) If you don't have permission to modify php.ini file , Or we want to set some pages separately . Then you can also PHP Set in the program page , The code is as follows ( The number 0 Indicates that there is no restriction on execution time ).
1
ini_set ( ‘max_execution_time’ , ‘0’ );
2, If you use IIS The server , Remember to revise “ Activity timed out ” Time
If it's in IIS Run under service PHP Program , You will find that after modification according to the previous method , An error will still be reported after a long operation . The error message is as follows :
HTTP error 500.0 - Internal Server Error
C:\websoft\php\php-cgi.exe - FastCGI The process exceeded the configured request timeout
terms of settlement : IIS -> FastCGI Set up -> double-click "php-cgi.exe" ->“ Activity timed out ” , Increase this value as needed .
边栏推荐
- Progress in architecture
- STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于GPIO)
- 【云原生】我怎么会和这个数据库杠上了?
- Error in find command: paths must precede expression (turn)
- Fs4059c is a 5V input boost charging 12.6v1.2a. Inputting a small current to three lithium battery charging chips will not pull it dead. The temperature is 60 ° and 1000-1100ma is recommended
- 【FAQ】華為帳號服務報錯 907135701的常見原因總結和解决方法
- The failure rate is as high as 80%. What are the challenges on the way of enterprise digital transformation?
- Golang uses JSON unmarshal number to interface{} number to become float64 type (turn)
- Test process arrangement (3)
- Chapter 17 process memory
猜你喜欢
MATLAB中tiledlayout函数使用
基于51单片机的超声波测距仪
Remove duplicate letters [greedy + monotonic stack (maintain monotonic sequence with array +len)]
What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?
[MySQL from introduction to proficiency] [advanced chapter] (V) SQL statement execution process of MySQL
数据湖(十三):Spark与Iceberg整合DDL操作
sharding key type not supported
Learn kernel 3: use GDB to track the kernel call chain
[FAQ] Huawei Account Service Error Report 907135701 Common reasons Summary and Solutions
Data center concept
随机推荐
File creation, writing, reading, deletion (transfer) in go language
QT how to detect whether the mouse is on a control
LiveData
R语言ggplot2可视化:gganimate包创建动画图(gif)、使用anim_save函数保存gif可视化动图
迅为IMX6Q开发板QT系统移植tinyplay
Leetcode 61: rotating linked list
Talk about 10 tips to ensure thread safety
codeforce:C. Sum of Substrings【边界处理 + 贡献思维 + 灵光一现】
为什么图片传输要使用base64编码
Visual Studio调试方式详解
架构方面的进步
MySQL stored procedure exercise
Introducing testfixture into unittest framework
一文概览2D人体姿态估计
流行框架:Glide的使用
C # WPF realizes the real-time screen capture function of screen capture box
Progress in architecture
scratch古堡历险记 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
Understand chisel language thoroughly 07. Chisel Foundation (IV) - bundle and VEC
学内核之三:使用GDB跟踪内核调用链