PHP - 检索包含或需要它的脚本的名称 [英] PHP - retrieve name of script that included or required it

查看:96
本文介绍了PHP - 检索包含或需要它的脚本的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检索包含或需要它的脚本的名称?

How do you retrieve the name of the script that included or required it?

示例:
脚本login.php有一个require_once('验证。 php')... validate.php也被许多其他脚本调用。除了手动设置标志之外,有没有办法让validate.php知道哪个脚本包含/要求它?

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?

推荐答案

尝试 $ _ SERVER ['SCRIPT_NAME'];

更多信息: http://php.net/manual/en/reserved.variables.server.php

这篇关于PHP - 检索包含或需要它的脚本的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆