Exception::getCode
(PHP 5, PHP 7, PHP 8)
Exception::getCode — 예외 코드를 가져옵니다.
설명
final public Exception::getCode(): int
예외 코드를 반환합니다.
매개변수
이 함수에는 매개변수가 없습니다.
반환 값
예외 코드를 Exception의 경우 int로 반환하지만 Exception 하위 항목의 경우 다른 유형(예: PDOException의 경우 문자열)으로 반환할 수 있습니다.
Examples
예제 #1 Exception::getCode() 예제
<?php
try {
throw new Exception("Some error message", 30);
} catch(Exception $e) {
echo "The exception code is: " . $e->getCode();
}
?>
위의 예는 다음과 유사한 결과를 출력합니다.
The exception code is: 30
기타
- Throwable::getCode() - 예외 코드를 가져옵니다.