try { // some code that may throw an exception } catch (Exception $e) { echo $e->getFile(); }
function someFunction() { throw new Exception('Error message'); } try { someFunction(); } catch (Exception $e) { echo $e->getFile(); }This example defines a function that throws an exception, then tries to call that function. When the exception is thrown, the `catch` block retrieves and echoes the path of the file where the exception was thrown. The `getFile` function is part of the PHP standard library and does not require any external packages or libraries.