PHP - Manual: Error::getCode
2025-02-27
(PHP 7, PHP 8)
Error::getCode — 获取错误代码
返回错误代码。
此函数没有参数。
返回 int 的错误代码
示例 #1 Error::getCode() 例子
<?phptry { throw new Error("Some error message", 30);} catch(Error $e) { echo "The Error code is: " . $e->getCode();}?>
以上示例的输出类似于:
The Error code is: 30
官方地址:https://www.php.net/manual/en/error.getcode.php