当前位置:网站首页>统计php程序运行时间及设置PHP最长运行时间
统计php程序运行时间及设置PHP最长运行时间
2022-07-04 12:51:00 【格格巫 MMQ!!】
"; $starttime = explode(" ",$pagestartime); $endtime = explode(" ",$pageendtime); $totaltime = $endtime[0]-$starttime[0]+$endtime[1]-$starttime[1]; $timecost = sprintf("%s",$totaltime); echo "页面运行时间: $timecost 秒"; ?>
通常来说,默认的PHP程序最大运行时间是30s,如果你的程序运行超过这个时间限制,那么会有类似Maximum execution time of 30 seconds exceeded的报错。
有几种解决办法:
首先先检查是不是你的在做一些傻事,从而消耗了大量的CPU资源及时间,如果确实需要程序长时间运行才能得出结果,那么可以
1> 在php.ini中增加运行时间:
max_execution_time=300
1.
2> 在PHP文件中添加如下代码
ini_set(‘max_execution_time’, 300); //300 seconds = 5 minutes
1.
3> 使用.htaccess文件来增加运行时间:
其他一些常见配置参考:
如果你的环境是wordpress,那么请在config.php中,添加:
define(‘WP_MEMORY_LIMIT’, ‘128M’);
1.
如果你使用了其他一些框架,可以修改
ini_set(‘memory_limit’, ‘128M’);
默认情况下, php.ini 中配置的最大执行时间是 30 秒,这是由 php.ini 中的 max_execution_time 变量指定的。如果我们有一个需要花费很多时间的工作,比如要发送大量邮件,或者要进行庞大的数据统计分析工作。即使任务没有执行完毕,服务器也会在 30 秒后强行中止正在执行的程序。
1,修改最长执行时间的两种方法
(1)直接修改 php.ini 中 max_execution_time 的数值。
(2)如果没权限修改 php.ini 文件,或者我们想对某些页面进行单独设置。那么也可以在 PHP 程序页面中进行设置,代码如下(数值 0 表示没有执行时间的限制)。
1
ini_set ( ‘max_execution_time’ , ‘0’ );
2,如果使用IIS服务器,记得还要修改“活动超时”时间
如果是在 IIS 服务下运行 PHP 程序,会发现根据前面的方法修改后,执行长时间的操作还是会报错。错误信息如下:
HTTP 错误 500.0 - Internal Server Error
C:\websoft\php\php-cgi.exe - FastCGI 进程超过了配置的请求超时时

解决办法: IIS -> FastCGI 设置-> 双击"php-cgi.exe" ->“活动超时” ,根据需求将这个值提高。

边栏推荐
- R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据
- docker-compose公网部署redis哨兵模式
- 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
- 做事的真正意义和目的,真正想得到什么
- 【信息检索】分类和聚类的实验
- Ruichengxin micro sprint technology innovation board: annual revenue of 367million, proposed to raise 1.3 billion, Datang Telecom is a shareholder
- Understand chisel language thoroughly 04. Chisel Foundation (I) - signal type and constant
- Programmer anxiety
- Understand chisel language thoroughly 03. Write to the developer of Verilog to chisel (you can also see it without Verilog Foundation)
- WS2818M是CPC8封装,是三通道LED驱动控制专用电路外置IC全彩双信号5V32灯可编程led灯带户外工程
猜你喜欢

软件测试之测试评估

【信息检索】分类和聚类的实验

【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法

CVPR 2022 | greatly reduce the manual annotation required for zero sample learning, and propose category semantic embedding rich in visual information (source code download)

Deming Lee listed on Shenzhen Stock Exchange: the market value is 3.1 billion, which is the husband and wife of Li Hu and Tian Hua

吃透Chisel语言.12.Chisel项目构建、运行和测试(四)——Chisel测试之ChiselTest
![Supprimer les lettres dupliquées [avidité + pile monotone (maintenir la séquence monotone avec un tableau + Len)]](/img/af/a1dcba6f45eb4ccc668cd04a662e9c.png)
Supprimer les lettres dupliquées [avidité + pile monotone (maintenir la séquence monotone avec un tableau + Len)]

基于PaddleX的智能零售柜商品识别

2022 practice questions and mock exams for the main principals of hazardous chemical business units

MATLAB中tiledlayout函数使用
随机推荐
R语言使用dplyr包的mutate函数对指定数据列进行标准化处理(使用mean函数和sd函数)并基于分组变量计算标准化后的目标变量的分组均值
Hardware Basics - diode Basics
Understand chisel language thoroughly 12. Chisel project construction, operation and testing (IV) -- chisel test of chisel test
Understand chisel language thoroughly 08. Chisel Foundation (V) -- wire, REG and IO, and how to understand chisel generation hardware
去除重複字母[貪心+單調棧(用數組+len來維持單調序列)]
Deming Lee listed on Shenzhen Stock Exchange: the market value is 3.1 billion, which is the husband and wife of Li Hu and Tian Hua
sharding key type not supported
Understand chisel language thoroughly 07. Chisel Foundation (IV) - bundle and VEC
软件测试之测试评估
Use the default route as the route to the Internet
Golang uses JSON unmarshal number to interface{} number to become float64 type (turn)
Yingshi Ruida rushes to the scientific and Technological Innovation Board: the annual revenue is 450million and the proposed fund-raising is 979million
吃透Chisel语言.07.Chisel基础(四)——Bundle和Vec
安装Mysql
[C question set] of VII
Understand chisel language thoroughly 11. Chisel project construction, operation and test (III) -- scalatest of chisel test
Introducing testfixture into unittest framework
Basic mode of service mesh
How to package QT and share exe
Apple 5g chip research and development failure: continue to rely on Qualcomm, but also worry about being prosecuted?