PHP - retrieve name of script that included or required it

梦想与她 提交于 2019-12-18 07:08:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!