獲取建立的異常所在檔案中的行號

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

參見

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *