Skip to content
PHP Logo

What is the function __FILE__ used for in PHP?

__FILE__ is a magic constant in PHP that returns the full path and filename of the current file. It is often used to include files relative to the current file's location or for debugging purposes to display the current file being executed.

php
// Example usage of __FILE__
echo "The current file is: " . __FILE__;