Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

getFile()

Example

Throw an exception and display the file path where the exception occurred.

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

Definition and Usage

The getFile() method returns the absolute path of the file where the exception was thrown.

Syntax

$exception->getFile()

Technical Details

Return Value:

Returns a string value.