PHP Velho Oeste 2024

Exception::getLine

(PHP 5, PHP 7, PHP 8)

Exception::getLineİstisnanın oluştuğu satırın numarası ile döner

Açıklama

final public Exception::getLine(): int

İstisnanın oluştuğu satırın numarası ile döner.

Bağımsız Değişkenler

Bu işlevin bağımsız değişkeni yoktur.

Dönen Değerler

İstisnanın oluştuğu satırın numarası ile döner.

Örnekler

Örnek 1 - Exception::getLine() örneği

<?php
try {
throw new
Exception("Bir hata iletisi");
} catch(
Exception $e) {
echo
"İstisnanın oluştuğu satırın numarası: " . $e->getLine();
}
?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

İstisnanın oluştuğu satırın numarası: 3

Ayrıca Bakınız

add a note add a note

User Contributed Notes 1 note

up
0
Festus Ngor
4 years ago
Exception::getTraceAsString — Gets the stack trace as a string. So use $e->getTraceAsString() i.e.:

<?php
try {
    throw new
Exception("Some error message");
} catch(
Exception $e) {
    echo
"The exception was created from: \n\r" . $e->getTraceAsString();
}
?>
To Top