Current Location: Home> Function Categories> getFile

getFile

Returns the full path to the file that threw the exception.
Name:getFile
Category:Uncategorized
Programming Language:php
One-line Description:Returns the full path to the file that threw the exception.

Definition and usage

getFile() method returns the absolute path to the file where the exception occurred.

Related pages

Tutorial: PHP exception

Example

Throw an exception and output the path to the file where the exception occurred:

 <?php
try {
  throw new Exception ( "An error occurred" ) ;
} catch ( Exception $e ) {
  echo "Error in this file: " . $e -> getFile ( ) ;
}
?>

Try it yourself

grammar

 $exception -> getFile ( )
Similar Functions
Popular Articles