array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'error.getline.php', 1 => 'Error::getLine', ), 'up' => array ( 0 => 'class.error.php', 1 => 'Error', ), 'prev' => array ( 0 => 'error.getfile.php', 1 => 'Error::getFile', ), 'next' => array ( 0 => 'error.gettrace.php', 1 => 'Error::getTrace', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'language/predefined/error/getline.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7, PHP 8)
Error::getLine — エラーが起きた行番号を取得する
この関数にはパラメータはありません。
エラーが起きた行番号を返します
例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