« Error::getFile
Error::getTrace »

Error::getLine

(PHP 7, PHP 8)

Error::getLine — エラーが起きた行番号を取得する

説明

final public function Error::getLine(): int

エラーが起きた行番号を取得します

パラメータ

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

戻り値

エラーが起きた行番号を返します

例

例1 Error::getLine() の例

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

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

The error was created on line: 3

参考

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

関連キーワード:
行番号   getLine   created   line   getFile   getTrace   final   throw   error message   catch   参考   Throwable   インスタンス
関連する関数・ページ:
throwable.getline   exception.getline   reflectionfunctionabstract.getendline   reflectionfunctionabstract.getstartline   reflectionfiber.getexecutingline   class.error