Exception
PHP 手册

Exception::getCode

(PHP 5 >= 5.1.0)

Exception::getCode — Gets the Exception code

说明

final public int Exception::getCode ( void )

Returns the Exception code.

参数

This function has no parameters.

返回值

Returns the Exception code as a integer.

范例

Example #1 Exception::getCode() example

<?php
try {
    throw new 
Exception("Some error message", 30);
} catch(
Exception $e) {
    echo 
"The exception code is: " . $e->getCode();
}
?>

上例的输出类似于:

The exception code is: 30


Exception
PHP 手册