php中捕获超时事件的方法实例

原创 2017-02-08 10:41:42 198
摘要:set_error_handler()不能捕获致命错误(具体错误类型见手册)。所以需要如下方法:<?php ini_set ( 'max_execution_time', 1 ); function shutdown() {  $a = error_get_last (); &

set_error_handler()不能捕获致命错误(具体错误类型见手册)。

所以需要如下方法:

<?php
ini_set ( 'max_execution_time', 1 );
function shutdown() {
 $a = error_get_last ();
 print_r ( $a );
}
register_shutdown_function ( 'shutdown' );
while ( true ) {
}

注意:sleep()停顿时间不算在max_execution_time中。

更多关于php中捕获超时事件的方法实例请关注PHP中文网(www.php.cn)其他文章!

发布手记

热门词条