当前位置:网站首页>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-05 17:29:00 【Game programming】
<?php $pagestartime=microtime(); ?> <?php Procedures section ?> <?php $pageendtime = microtime(); echo $pageendtime."
"; $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 .

author : Gegwu MMQ!!
Game programming , A game development favorite ~
If the picture is not displayed for a long time , Please use Chrome Kernel browser .
边栏推荐
- Check the WiFi password connected to your computer
- Winedt common shortcut key modify shortcut key latex compile button
- IDC报告:腾讯云数据库稳居关系型数据库市场TOP 2!
- Mysql5.6 parsing JSON strings (supporting complex nested formats)
- 编译libssh2报错找不到openssl
- thinkphp3.2.3
- Use byte stream to read Chinese from file to console display
- Embedded-c Language-2
- Is it safe and reliable to open futures accounts on koufu.com? How to distinguish whether the platform is safe?
- Rider 设置选中单词侧边高亮,去除警告建议高亮
猜你喜欢

Embedded UC (UNIX System Advanced Programming) -1

北京内推 | 微软亚洲研究院机器学习组招聘NLP/语音合成等方向全职研究员
![[Web attack and Defense] WAF detection technology map](/img/7c/60a25764950668ae454b2bc08fe57e.png)
[Web attack and Defense] WAF detection technology map
mysql中取出json字段的小技巧

CVPR 2022 best student paper: single image estimation object pose estimation in 3D space
一文了解MySQL事务隔离级别

Kafaka technology lesson 1

Embedded UC (UNIX System Advanced Programming) -3

Machine learning 02: model evaluation

High number | summary of calculation methods of volume of rotating body, double integral calculation of volume of rotating body
随机推荐
2022 年 Q2 加密市场投融资报告:GameFi 成为投资关键词
CVPR 2022最佳学生论文:单张图像估计物体在3D空间中的位姿估计
基于51单片机的电子时钟设计
thinkphp模板的使用
Kafaka技术第一课
Cloud security daily 220705: the red hat PHP interpreter has found a vulnerability of executing arbitrary code, which needs to be upgraded as soon as possible
Design of electronic clock based on 51 single chip microcomputer
Judge whether a string is a full letter sentence
Beijing internal promotion | the machine learning group of Microsoft Research Asia recruits full-time researchers in nlp/ speech synthesis and other directions
Rider set the highlighted side of the selected word, remove the warning and suggest highlighting
MySQL之知识点(七)
Embedded-c Language-2
URP下Alpha从Gamma空间到Linner空间转换(二)——多Alpha贴图叠加
Matery主题自定义(一)黑夜模式
Read the history of it development in one breath
Is it safe to open an account for digging wealth stocks? How is it safe to open a stock account?
ClickHouse(03)ClickHouse怎么安装和部署
MySQL queries the latest qualified data rows
Is it safe for qiniu business school to open a stock account? Is it reliable?
一文了解Go语言中的函数与方法的用法