获取包含PHP脚本的文件的名称 [英] Get name of file that is including a PHP script
本文介绍了获取包含PHP脚本的文件的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我要执行的操作的示例:
Here is an example of what I am trying to do:
<ul><?php include("list.php") ?></ul>
list.php
<?php
if (PAGE_NAME is index.php) {
//Do something
}
else {
//Do something
}
?>
如何获取包含list.php脚本(PAGE_NAME)的文件的名称?我已经尝试过basename(__FILE__)
,但这给了我list.php
.
How can I get the name of the file that is including the list.php script (PAGE_NAME)? I have tried basename(__FILE__)
, but that gives me list.php
.
推荐答案
$_SERVER["PHP_SELF"];
返回您想要的内容
这篇关于获取包含PHP脚本的文件的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文