当前位置:网站首页>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 .
边栏推荐
- Why should Base64 encoding be used for image transmission
- R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, and uses the by parameter to specify the groupin
- leetcode:6110. 网格图中递增路径的数目【dfs + cache】
- Test process arrangement (2)
- 【MySQL从入门到精通】【高级篇】(四)MySQL权限管理与控制
- 游戏出海,全球化运营
- scratch古堡历险记 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
- R language dplyr package summary_ If function calculates the mean and median of all numerical data columns in dataframe data, and summarizes all numerical variables based on conditions
- 92.(cesium篇)cesium楼栋分层
- 【FAQ】華為帳號服務報錯 907135701的常見原因總結和解决方法
猜你喜欢
随机推荐
【云原生】我怎么会和这个数据库杠上了?
Gorm read / write separation (rotation)
迅为IMX6Q开发板QT系统移植tinyplay
【算法leetcode】面试题 04.03. 特定深度节点链表(多语言实现)
leetcode:6109. 知道秘密的人数【dp的定义】
Detailed index of MySQL
RK1126平台OSD的实现支持颜色半透明度多通道支持中文
How to operate and invest games on behalf of others at sea
flink sql-client.sh 使用教程
How to package QT and share exe
What is the difference between Bi financial analysis in a narrow sense and financial analysis in a broad sense?
Oppo find N2 product form first exposure: supplement all short boards
R语言使用dplyr包的mutate函数对指定数据列进行标准化处理(使用mean函数和sd函数)并基于分组变量计算标准化后的目标变量的分组均值
瑞吉外卖笔记
Test process arrangement (2)
Ws2818m is packaged in cpc8. It is a special circuit for three channel LED drive control. External IC full-color double signal 5v32 lamp programmable LED lamp with outdoor engineering
Blob, text geometry or JSON column'xxx'can't have a default value query question
MySQL stored procedure exercise
游戏出海,全球化运营
【MySQL从入门到精通】【高级篇】(四)MySQL权限管理与控制