PHP Exception 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 »
Definition and Usage
The getLine()
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 our PHP Exceptions Chapter.
❮ PHP Exception Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.