php8.5
Home/ Manual/ predefined / exception/ Exception::getFile

Exception::getFile

PHP function Edit on GitHub ✎

(PHP 5, PHP 7, PHP 8)

Gets the file in which the exception was created

Description

Exception::getFile(): string

Get the name of the file in which the exception was created.

Parameters Parameters

Return Values

Returns the filename in which the exception was created.

Examples

Exception::getFile() example

php
<?php
try {
    throw new Exception;
} catch(Exception $e) {
    echo $e->getFile();
}
?>

The above example will output something similar to:

output
/home/bjori/tmp/ex.php

See Also

  • Throwable::getFile

Source: language/predefined/exception/getfile.xml · from the official PHP manual (php/doc-en)