PHP.nl

Exception::getCode

Exception::getCode

Gets the Exception code

int **Exception::getCode**

Returns the Exception code.

Returns the exception code as in but possibly as other type in descendants (for example as in ). int``Exception``Exception``string``PDOException

Voorbeeld: 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

Throwable::getCode

Documentatie