« Exception::getFile
Exception::getTrace »

Exception::getLine

(PHP 5, PHP 7, PHP 8)

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

説明

final public function Exception::getLine(): int

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

パラメータ

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

戻り値

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

例

例1 Exception::getLine() の例

<?php
try {
    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() - オブジェクトのインスタンスが作られた行番号を取得する

関連キーワード:
Exception   getLine   行番号   exception   created   line   getFile   getTrace   final   throw   error message   catch   参考   Throwable   インスタンス
関連する関数・ページ:
error.getline   throwable.getline   exception.getfile   class.com-exception   class.zmqexception   class.yaf-exception