Error::getCode
PHP function
Edit on GitHub ✎
(PHP 7, PHP 8)
Gets the error code
Description
Error::getCode(): int
Returns the error code.
Parameters Parameters
Return Values
Returns the error code as int
Examples
Error::getCode() example
php
<?php
try {
throw new Error("Some error message", 30);
} catch(Error $e) {
echo "The Error code is: " . $e->getCode();
}
?>The above example will output something similar to:
output
The Error code is: 30See Also
Throwable::getCode