PHP set_exception_handler() 함수
예시
사용자 정의 예외 처리기 기능을 설정합니다.
<?php
// A user-defined exception handler function
function myException($exception)
{
echo "<b>Exception:</b> ", $exception->getMessage();
}
// Set user-defined exception handler function
set_exception_handler("myException");
// Throw exception
throw new Exception("Uncaught exception occurred!");
?>
정의 및 사용
set_exception_handler() 함수는 사용자 정의 예외 처리기 함수를 설정합니다.
예외 처리기가 호출된 후 스크립트 실행이 중지됩니다.
통사론
set_exception_handler(exceptionhandler);
매개변수 값
Parameter | Description |
---|---|
exceptionhandler | Required. Specifies the name of the function to be run when an uncaught exception occurs. NULL can be passed instead, to reset this handler to its default state |
기술적 세부 사항
반환 값: | 이전에 정의된 예외 처리기를 포함하는 문자열 또는 오류가 발생하거나 이전 처리기가 정의되지 않은 경우 NULL |
---|---|
PHP 버전: | 5.0+ |
PHP 변경 로그: | 이전에는 NULL이 전달되면 이 함수는 TRUE를 반환했습니다. PHP 5.5 이후의 이전 핸들러를 반환합니다. |
PHP 오류 참조