array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'error.getcode.php', 1 => 'Error::getCode', ), 'up' => array ( 0 => 'class.error.php', 1 => 'Error', ), 'prev' => array ( 0 => 'error.getprevious.php', 1 => 'Error::getPrevious', ), 'next' => array ( 0 => 'error.getfile.php', 1 => 'Error::getFile', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'language/predefined/error/getcode.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7, PHP 8)
Error::getCode — Gets the error code
This function has no parameters.
Returns the error code as int
Example #1 Error::getCode() example
<?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:
The Error code is: 30