PHP include within include 无效

PHP include within include not working

我有以下设置:

index.php(在 root 中)包括 results.php(也在 root 中)

<?php include("results.php"); ?>

在结果中,我包含了另一个使用 URI(我用变量设置)的文件来获取正确的目录,因为我使用重写来根据用户输入使 "results page" 不同.

所以,里面 results.php:

<?php include($website['uri'] . 'elements/keywords.php'); ?>

作为参考,当我尝试将上面的内容设为 link 时,它通过了。

<a href="<?php echo $website['uri']."elements/keywords.php"; ?>">Test</a>

我可以单击 link 并且没有问题,但是当我尝试包含它时绝对没有任何反应。我的results.php包含在index.php里面就好了。

任何人都可以提供一些技巧来使它正常工作吗?

更新:$website['uri'] 已设置且始终为“/seo-project/”,这是我在其中工作的目录(index.php 所在的目录)。用相对路径替换变量什么都不做,但仍然适用于 link.

不要使用 BASE URL,而是使用物理路径。从路径

中删除 $website['uri'] 部分