Exception::getLine
(PHP 5, PHP 7, PHP 8)
Exception::getLine — 獲取建立的異常所在檔案中的行號
說明
final public Exception::getLine(): int
返回發生異常的程式碼在檔案中的行號。
參數
此函式沒有參數。
返回值
返回發生異常的程式碼在檔案中的行號。
範例
示例 #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