PHPException getLine() Method
Example
Throw an exception and then output the number of the line on which it was thrown:
<?php
try {
throw new Exception("An error occurred");
} catch(Exception $e) {
echo $e->getLine();
}
?>
Try it Yourself »try {
throw new Exception("An error occurred");
} catch(Exception $e) {
echo $e->getLine();
}
?>
Definition and Usage
ThegetLine() method returns the line number of the line of code which threw the exception.
Syntax
$exception->getLine()
Technical Details
| Return Value: | Returns an integer |
|---|
Related Pages
Read more about Exceptions in ourPHP Exceptions Chapter.
❮ PHP Exception Reference

