« Error::getPrevious
Error::getFile »

Error::getCode

(PHP 7, PHP 8)

Error::getCode — エラーコードを取得する

説明

final public function Error::getCode(): int

エラーコードを返します

パラメータ

この関数にはパラメータはありません。

戻り値

エラーコードを int 型として返します

例

例1 Error::getCode() の例

<?php
try {
    throw new Error("Some error message", 30);
} catch(Error $e) {
    echo "The Error code is: " . $e->getCode();
}
?>

上の例の出力は、 たとえば以下のようになります。

The Error code is: 30

参考

関連キーワード:
getCode   エラーコード   code   getPrevious   getFile   final   throw   error message   catch   参考   Throwable   コード
関連する関数・ページ:
throwable.getcode   exception.getcode   function.fdf-error   xml.error-codes   mysqli-sql-exception.getsqlstate   function.fdf-errno