为什么php或apache不停止无限循环?
while (true)
{
sleep(5);
}
Apache默认TimeOut = 300。Php - max_execution_time = 30
但是这个循环可以工作超过一个小时。为什么?
由于sleep()发生在脚本之外,因此它不会影响脚本的最大执行时间。
注意:set_time_limit()函数和配置指令Max_execution_time只影响脚本的执行时间本身。任何花费在执行之外的活动上的时间对于诸如使用system()的系统调用之类的脚本,sleep()函数、数据库查询等在确定脚本运行的最长时间。http://php.net/manual/en/function.sleep.php