好的,我在每个页面上创建一个网站,我想include
一个文件sidebar.php。文件'包括''包括'的回声名称
在sidebar.php我想回显包含sidebar.php文件的名称。
下面是sidebar.php的内容,它们返回'sidebar'。
<?php
$file = basename(__FILE__, '.php');
echo $file;
;?>
我发现了一个similar question但是整个的一点是,我没有做任何变量在每个页面上。
请原谅我单词'include'的模糊用法,我使用它作为php中的陈述。
这听起来像一个[XY问题(HTTP://meta.stackexchange .COM /问题/ 66377 /什么,是最XY-问题)。 *为什么*你需要这个?可能有更好的方法。 – h2ooooooo
包含'sidebar.php'的文件是URI中请求的脚本吗? '$ _SERVER'可能已经有了你想要的值(虽然像@ h2ooooooo,我怀疑有更好的办法) –
h2ooooooo我愿意说你是对的。 – sgp667