Exception::getLine

(PHP 5, PHP 7, PHP 8)

Exception::getLine獲取創(chuàng)建的異常所在文件中的行號(hào)

說明

final public Exception::getLine(): int

返回發(fā)生異常的代碼在文件中的行號(hào)。

參數(shù)

此函數(shù)沒有參數(shù)。

返回值

返回發(fā)生異常的代碼在文件中的行號(hào)。

范例

示例 #1 Exception::getLine()示例

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

以上例程的輸出類似于:

The exception was thrown on line: 3

參見