array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), '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

Опис

final public Exception::getCode(): int

Returns the Exception code.

Параметри

У цієї функції немає параметрів.

Значення, що повертаються

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

Приклади

Приклад #1 Exception::getCode() 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

Прогляньте також