restore_exception_handler 함수
restore_exception_handler 함수는 set_exception_handler를 사용하여 대체된 이전 예외 핸들러를
복원합니다. 이 함수는 매개변수를 받지 않으며 값을 반환하지 않습니다.
구문
restore_exception_handler();
예제
사용자 정의 예외 핸들러를 설정한 후 이전 핸들러를 복원해 봅시다:
<?php
function customExceptionHandler($exception) {
echo 'Custom handler: ' . $exception->getMessage();
}
set_exception_handler('customExceptionHandler');
restore_exception_handler();
?>
예제
복원 후 표준 메커니즘이 작동하는지 확인해 봅시다:
<?php
set_exception_handler(function($exception) {
echo 'Handler 1: ' . $exception->getMessage();
});
set_exception_handler(function($exception) {
echo 'Handler 2: ' . $exception->getMessage();
});
restore_exception_handler();
throw new Exception('Test error');
?>
코드 실행 결과:
'Handler 1: Test error'