php8.5
Home/ Manual/ predefined / error/ Error::getLine

Error::getLine

PHP function Edit on GitHub ✎

(PHP 7, PHP 8)

Gets the line in which the error occurred

Description

Error::getLine(): int

Get line number where the error occurred.

Parameters Parameters

Return Values

Returns the line number where the error occurred.

Examples

Error::getLine() example

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

The above example will output something similar to:

output
The error was created on line: 3

See Also

  • Throwable::getLine

Source: language/predefined/error/getline.xml · from the official PHP manual (php/doc-en)