欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP函數(shù)超時處理方法

 更新時間:2016年02月14日 10:51:41   作者:思齊_  
這篇文章主要介紹了PHP函數(shù)超時處理方法,結(jié)合實例形式分析了基于register_shutdown_function的超時處理相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了PHP函數(shù)超時處理方法。分享給大家供大家參考,具體如下:

register_shutdown_function

Registers the function named by function to be executed when script processing is complete or when exit() is called.

此函數(shù)可以重復(fù)注冊,然后會依次調(diào)用 當(dāng)發(fā)生致命性錯誤或者exit時都會調(diào)用此函數(shù)

error_reporting(0);
register_shutdown_function ( 'handleShutdown' );
function handleShutdown (){
  $error = error_get_last ();
  // 根據(jù)錯誤信息,判斷是否是超時了
  if ( $error && strpos ( $error [ 'message' ], 'Maximum exec' )!== false )
  {
    echo 'handle time out';
  }
}
set_time_limit(2);
sleep(3);

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP基本語法入門教程》、《PHP錯誤與異常處理方法總結(jié)》及《php常用函數(shù)與技巧總結(jié)

希望本文所述對大家PHP程序設(shè)計有所幫助。

相關(guān)文章

最新評論