《PHP應用:PHP函數(shù)超時處理方法》要點:
本文介紹了PHP應用:PHP函數(shù)超時處理方法,希望對您有用。如果有疑問,可以聯(lián)系我們。
PHP編程本文實例講述了PHP函數(shù)超時處理辦法.分享給大家供大家參考,具體如下:
PHP編程register_shutdown_function
PHP編程Registers the function named by function to be executed when script processing is complete or when exit() is called.
PHP編程此函數(shù)可以重復注冊,然后會依次調(diào)用 當發(fā)生致命性錯誤或者exit時都會調(diào)用此函數(shù)
PHP編程
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);
PHP編程更多關于PHP相關內(nèi)容感興趣的讀者可查看本站專題:《PHP基本語法入門教程》、《PHP錯誤與異常處理辦法總結(jié)》及《php常用函數(shù)與技巧總結(jié)》
PHP編程希望本文所述對大家PHP程序設計有所贊助.
維易PHP培訓學院每天發(fā)布《PHP應用:PHP函數(shù)超時處理方法》等實戰(zhàn)技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培養(yǎng)人才。
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.snjht.com/jiaocheng/7555.html