array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'it', ), 'this' => array ( 0 => 'exception.getcode.php', 1 => 'Exception::getCode', 2 => 'Gets the Exception code', ), 'up' => array ( 0 => 'class.exception.php', 1 => 'Exception', ), 'prev' => array ( 0 => 'exception.getprevious.php', 1 => 'Exception::getPrevious', ), 'next' => array ( 0 => 'exception.getfile.php', 1 => 'Exception::getFile', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'language/predefined/exception/getcode.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 5, PHP 7, PHP 8)
Exception::getCode — Gets the Exception code
Questa funzione non contiene parametri.
Returns the exception code as int in Exception but possibly as other type in Exception descendants (for example as string in PDOException).
Example #1 Exception::getCode() example
<?php
try {
throw new Exception("Some error message", 30);
} catch(Exception $e) {
echo "The exception code is: " . $e->getCode();
}
?>
Il precedente esempio visualizzerĂ qualcosa simile a:
The exception code is: 30