Throw an exception and output its code:
<?php
try {
throw new Exception("An error occurred", 120);
} catch(Exception $e) {
echo "Error code: " . $e->getCode();
}
?>
Try it Yourself »
The getCode()
method returns an integer which can be used to identify the exception.
$exception->getCode()
Return Value: | Returns an integer |
---|
Read more about Exceptions in our PHP Exceptions Chapter.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!