PHP Velho Oeste 2024

Exception::getLine

(PHP 5, PHP 7, PHP 8)

Exception::getLineObtiene la línea en el que se creó la excepción

Descripción

final public Exception::getLine(): int

Devuelve el número de la línea donde se creó la excepción.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Devuelve el número de la línea donde se creó la excepción.

Ejemplos

Ejemplo #1 Ejemplo de Exception::getLine()

<?php
try {
throw new
Exception("Algún mensaje de error");
} catch(
Exception $e) {
echo
"La excepción se creó en la línea: " . $e->getLine();
}
?>

El resultado del ejemplo sería algo similar a:

La excepción se creó en la línea: 3

Ver también

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