PHP包括不一致的工作


PHP include inconsistently working

我在使用PHP的include函数时总是遇到问题。我正在制作一个商店网站,我已经创建了一个购物车。我希望它在每几个页面的侧边栏,所以我使用包括。

文件/public_html/product/index.php第37行:include("converter.php");

文件converter.php在/public_html/include/converter.php

有时它似乎可以工作,但大多数时候它显示:

警告:include(converter.php) [function. php]。

第37行/public_html/product/index.php中没有这样的文件或目录

然后

警告:include() [function.][include]:在/home/a3371827/public_html/product/index.php第37行,为包含(include_path='.:/usr/lib/php:/usr/local/lib/php')打开'converter.php'失败

我错过了什么包括??

路径错误。使用:

include("../include/converter.php");

可能是目录路径问题。尝试使用include_once("../include/converter.php");或使用print getcwd();进一步调试,然后使用chdir();设置正确的路径。

编辑:你的问题漏掉了文件夹路径,修复

您要查找的文件没有(直接或间接)在include_path中列出的任何路径下。