Hello, i have this:
parent.php:
require_once 'child.php';
child.php:
echo __FILE__;
It will show '.../child.php'
How can i get '.../parent.php'
Hello, i have this:
parent.php:
require_once 'child.php';
child.php:
echo __FILE__;
It will show '.../child.php'
How can i get '.../parent.php'
Hi,
I don't think you can do that : the __FILE__
magic constant indicates in which file it is written ; and that is all.
If you want to know which PHP script was initially called (which URL was requested, for instance), you might have more luck looking at the $_SERVER
superglobal : it contains many informations, including some that will help you (like SCRIPT_FILENAME
or SCRIPT_NAME
, for instance) ;-)