Possible Duplicate:
PHP - retrieve name of script that included or required it
Is there a way in PHP to get which file required/included the current file? For example:
<?php
include("add-person.php");
?>
<?php
echo get_parent(); //should return controller.php
?>
php -f controller.php
Basically, something like the made-up function get_parent(). Thanks.
I know of a "not so clean" way. Try going through the array debug_backtrace() gives you. Among other things it contains a hierarchy how the code processed through include files. Manual here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With