max-execution-time与set-time-limit两个函数是什么关系?

问题描述:

max_execution_time与set_time_limit两个函数是什么关系?
1个回答 分类:综合 2014-11-28

问题解答:

我来补答
max_execution_time 在php.ini中设置
set_time_limit() 在php程序中设置
这方面的文章很多,可以搜索一下.
下面一段引自:http://blog.xiuwz.com/2012/09/25/php-max-execution-time-internal/
官网上set_time_limit函数所说:
The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real.
max_execution_time计算的只是PHP脚本本身执行的时间,执行之外的时间都不会计算在内.哪些属于执行之外的时间呢?包含sleep、数据交互、socket交互等等.
下面一段引自:http://baike.baidu.com/view/2317836.htm
void set_time_limit ( int $seconds )
设置允许脚本运行的时间,单位为秒.如果超过了此设置,脚本返回一个致命的错误.默认值为30秒,或者是在php.ini的max_execution_time被定义的值,如果此值存在.
当此函数被调用时,set_time_limit()会从零开始重新启动超时计数器.换句话说,如果超时默认是30秒,在脚本运行了了25秒时调用 set_time_limit(20),那么,脚本在超时之前可运行总时间为45秒.
 
 
展开全文阅读
剩余:2000
上一页:画钩的
下一页:速率