我有以下PHP脚本放置在我的虚拟主机服务器的根目录中,它工作正常。在Linux上的LiteSpeed Web服务器上正确的文件路径
include(dirname(__FILE__).'/config/config.inc.php');
require_once(dirname(__FILE__).'/init.php');
当我移动的脚本到一个新的文件夹下我的Web根,即public_html/myfolder,脚本提供了以下错误:
Warning: include(/home/name/public_html/folder/config/config.inc.php) [function.include]: failed to open stream: No such file or directory in /home/name/public_html/folder/test.php on line 2
Warning: include() [function.include]: Failed opening '/home/name/public_html/folder/config/config.inc.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/name/public_html/folder/test.php on line 2
Warning: require_once(/home/name/public_html/folder/init.php) [function.require-once]: failed to open stream: No such file or directory in /home/name/public_html/folder/test.php on line 3
Fatal error: require_once() [function.require]: Failed opening required '/home/name/public_html/folder/init.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/name/public_html/folder/test.php on line 3
我应该改变的路径如下:
include(dirname(__FILE__).'/../config/config.inc.php');
require_once(dirname(__FILE__).'/../init.php');
我正确吗?
2013-05-28
triwo
+0
我敢打赌,自己试试它会容易一些。无论如何,这些文件需要包含在哪里?当你包括一些东西时,你只需要检查包含的文件是否真的在那里:) –
+0
它可以工作,但我想确保我是正确的。这些文件位于:'public_html/config/config.inc.php'和 'public_html/init.php' –
+0
'echo dirname(__ FILE __);'输出给你什么? –