【发布时间】:2013-03-23 03:49:02
【问题描述】:
我有 example1.php 和 example2.php,其中包括 example3.php。在example3.php 我有:
<link rel="canonical" href="http://website.com/<?php echo basename(__FILE__); ?>">
我想要的是在href 中拥有example1.php/example2.php,这取决于文件包括 example3.php。问题当然是__FILE__ 输出example3.php。是否可以获取包含文件的文件名,而不是包含的文件名?
请不要建议使用易受攻击的 XSS SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']。
【问题讨论】:
-
您可以在“包括”之前设置一个变量,然后引用该变量。很痛苦,但它会起作用。
标签: php httprequest canonical-link http-host