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); ?>

Exception::getCode

(PHP 5, PHP 7, PHP 8)

Exception::getCodeGets the Exception code

Descrizione

final public Exception::getCode(): int

Returns the Exception code.

Elenco dei parametri

Questa funzione non contiene parametri.

Valori restituiti

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

Esempi

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

Vedere anche: