亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

本文實(shí)例講述了PHP函數(shù)超時(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ù)注冊(cè),然后會(huì)依次調(diào)用 當(dāng)發(fā)生致命性錯(cuò)誤或者exit時(shí)都會(huì)調(diào)用此函數(shù)

error_reporting(0);
register_shutdown_function ( 'handleShutdown' );
function handleShutdown (){
  $error = error_get_last ();
  // 根據(jù)錯(cuò)誤信息,判斷是否是超時(shí)了
  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錯(cuò)誤與異常處理方法總結(jié)》及《php常用函數(shù)與技巧總結(jié)

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

相關(guān)文章

最新評(píng)論