一张运行时间好长非常多重循环的读取数据库的页面,常常运行着就变白屏了,起初还想不到问题所在,后来突然想到可能是运行时间过长引起的,而通常Web服务器运行一个网页是有时间限制的。
使php执行时间无限长的方法
1、程序里修改: set_time_limit(0);
2、配置php.ini:max_execution_time = 0
配置该页最久执行时间 (PHP 3, PHP 4, PHP 5)。
语法: void set_time_limit(int seconds);
返回值: 无
函数种类: PHP 系统功能
内容说明
本函数用来配置该页最久执行时间。默认值是 30 秒,在 php.ini 中的 max_execution_time 变量配置,若配置为 0 则不限定最久时间。当执行到该函数时,才开始计算。例如,若默认是 30 秒,而在执行到该函数前已执行了 25 秒,而用本函数改为 20 秒,则该页面最长执行时间为 45 秒。
Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.
When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.
添加了set_time_limit(0)果然就好用了.