這篇文章主要介紹了PHP中捕獲超時事件的方法實例,本文直接給出示例代碼,需要的朋友可以參考下
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中。
新聞熱點
疑難解答