PHP에서이 오류와 관련된 많은 질문을 보았습니다. 그러나 시간 제한을 설정하는 모든 솔루션이 제공됩니다.런타임에서 최대 실행 시간 감지
하지만 내가하고 싶은 것은 오류를 감지하고 오류가 발생하면 다른 작업 과정으로 전환하는 것입니다. 내 요청이 내 최대 시간을 초과하면 오류 메시지가 나타나서 멈추지 않고 코드의 다른 블록을 계속 실행해서는 안됩니다. 어떻게하면됩니까? 난 그냥이 코드를 발견
=======은 도움이 될 수 있습니다, 사이트입니까?
<?php
//open error reporting, the error message is required in this script
error_reporting(1);
//for testing, set maximum execution to 1 second
set_time_limit(1);
//turn on output buffering and set callback function
ob_start('callback');
//------------------------------------------------------------------------------
//main program(dead loop)
while (true);
//script completed(impossible)
echo 'Completed!';
//------------------------------------------------------------------------------
/**
* output callback, execute when end of the request
*
* @param string $buffer
* @return string
*/
function callback($buffer) {
if (false !== (stripos($buffer,'<b>Fatal error</b>'))) {
if (false !== (stripos($buffer,'Maximum execution'))) {
$buffer = 'ycTIN.com , Server Busy';
} else {
$buffer = 'ycTIN.com , Server Internal Error';
}
}
return $buffer;
}
?>
오류 처리기를 사용하지 않으시겠습니까? 나는 그것이 치명적인 오류임을 보여줍니다. : - \ –
치명적인 오류는 PHP의 사용자 정의 오류 처리기로 처리 할 수 없습니다. – ThiefMaster