当前位置:网站首页>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 .
边栏推荐
- 去除重复字母[贪心+单调栈(用数组+len来维持单调序列)]
- 聊聊保证线程安全的 10 个小技巧
- Redis daily notes
- Introducing testfixture into unittest framework
- QT how to detect whether the mouse is on a control
- Understand chisel language thoroughly 12. Chisel project construction, operation and testing (IV) -- chisel test of chisel test
- 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
- AI and Life Sciences
- 数据埋点的一些问题和想法
- Understand chisel language thoroughly 10. Chisel project construction, operation and testing (II) -- Verilog code generation in chisel & chisel development process
猜你喜欢
随机推荐
Understand chisel language thoroughly 08. Chisel Foundation (V) -- wire, REG and IO, and how to understand chisel generation hardware
Use of arouter
How to operate and invest games on behalf of others at sea
为什么图片传输要使用base64编码
Leetcode T49: 字母异位词分组
Learning projects are self-made, and growth opportunities are self created
Digi重启XBee-Pro S2C生产,有些差别需要注意
ML之shap:基于boston波士顿房价回归预测数据集利用shap值对XGBoost模型实现可解释性案例
R语言使用dplyr包的group_by函数和summarise函数基于分组变量计算目标变量的均值、标准差
Gorm read / write separation (rotation)
redis 日常笔记
LiveData
R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据
Map of mL: Based on Boston house price regression prediction data set, an interpretable case of xgboost model using map value
R语言使用lattice包中的bwplot函数可视化箱图(box plot)、par.settings参数自定义主题模式
vscode 常用插件汇总
R语言使用dplyr包的mutate函数对指定数据列进行标准化处理(使用mean函数和sd函数)并基于分组变量计算标准化后的目标变量的分组均值
R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat
Common content type correspondence table
opencv3.2 和opencv2.4安装