Php/docs/exception.getline

提供:Dev Guides
< Php
2020年12月14日 (月) 11:22時点におけるNotes (トーク | 投稿記録)による版 (autoload)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

Exception::getLine

(PHP 5, PHP 7, PHP 8)

Exception::getLine例外が作られた行を取得する


説明

final public Exception::getLine ( ) : int

例外が作られた行番号を取得します。


パラメータ

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


返り値

例外が作られた行番号を返します。


例1 Exception::getLine() の例

<?phptry {    throw new Exception("Some error message");} catch(Exception $e) {    echo "The exception was created on line: " . $e->getLine();}?>

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


The exception was created on line: 3

参考

  • Throwable::getLine() - オブジェクトのインスタンスが作られた行番号を取得する