问题
How do you retrieve the name of the script that included or required it?
Example: script login.php has a require_once('validate.php') ... validate.php is also called by a number of other scripts. Other than manually setting a flag, is there a way to have validate.php know which script is including/requiring it?
回答1:
Try $_SERVER['SCRIPT_NAME'];
More here: http://php.net/manual/en/reserved.variables.server.php
来源:https://stackoverflow.com/questions/3278757/php-retrieve-name-of-script-that-included-or-required-it