PHP Exception getFile() Method
Example
Throw an exception and output the path of the file in which the exception occurred:
<?php
try {
throw new Exception("An error occurred");
}
catch(Exception $e) {
echo "Error in this file: " . $e->getFile();
}
?>
Try it Yourself »
Definition and Usage
The getFile()
method returns the absolute path to the file where an exception occurred.
Syntax
$exception->getFile()
Technical Details
Return Value: | Returns a string |
---|
Related Pages
Read more about Exceptions in our PHP Exceptions Chapter.
❮ PHP Exception Reference