Exception/getcode-Phpdoc专题

Exception::getCode

获取异常代码

说明

final public mixed <span class="methodname">Exception::getCode ( <span class="methodparam">void )

返回异常代码。

参数

此函数没有参数。

返回值

Exception 返回整型(<span class="type">int)的异常代码,但在其他类中可能返回其他类型(比如在 PDOException 中返回 <span class="type">string)。

范例

示例 #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

本站为非盈利网站,作品由网友提供上传,如无意中有侵犯您的版权,请联系删除