PHP set_include_路径配置

PHP set_include_路径配置,php,linux,debian,Php,Linux,Debian,我对set_include_路径有问题,我读了很多关于这个问题的信息,但是没有一条对我有效。 我在Debian上,我的根目录将设置为/home/project/ 所以我尝试了四种不同的方法: ini_set("include_path", '/home/project'); ini_set("include_path", '.:/home/project'); set_include_path('.:/home/project'); set_include_path('/home/project

我对set_include_路径有问题,我读了很多关于这个问题的信息,但是没有一条对我有效。 我在Debian上,我的根目录将设置为/home/project/

所以我尝试了四种不同的方法:

ini_set("include_path", '/home/project');
ini_set("include_path", '.:/home/project');
set_include_path('.:/home/project');
set_include_path('/home/project');
set_include_path(get_include_path().PATH_SEPARATOR.'/home/project');
但是没有一个是有效的。。。当我执行echo get_include_path()时;每次看起来都不错

但第四种方法在我的计算机上与WAMP完美结合

关于所有这些的错误消息:

Warning: include(/config/config.php) [function.include]: failed to open stream: No such file or directory in /home/project/web/www.project.com/index.php on line 3

Warning: include() [function.include]: Failed opening '/config/config.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear:/home/project') in /home/project/web/www.project.com/index.php on line 3

使用以下命令设置:
Set_include_path(get_include_path().path_SEPARATOR./path/)
,这不会删除由其他脚本设置的现有include\u路径,并添加默认的系统路径分隔符。

尝试使用文档中的
路径分隔符

set_include_path(get_include_path() . PATH_SEPARATOR . $path);
可能在部署应用程序的系统上有所不同

更新: include路径似乎很好,但问题有所不同

你不应该包括:

require '/config/config.php'
但是


因此,删除前导斜杠,它应该可以工作。

路径分隔符可能不同

set_include_path(implode(PATH_SEPARATOR, array(
    '.',
    '/home/project',
    get_include_path()
));

通过此操作,您可以将当前包含路径附加到您自己添加的路径,并为每个系统提供正确的路径分隔符。

您能否在尝试包含文件时发布错误信息?它通常会打印出所使用的include路径。它变了吗?很抱歉我需要离开工作区,但如果我在同一个文件夹中包含一个文件,会发生什么?总是包含路径中的第一个文件。啊,我刚刚学到了一些我不知道的东西。。。它从左到右测试get_include_path()中的所有路径。好的,我没问题:-)谢谢
set_include_path(implode(PATH_SEPARATOR, array(
    '.',
    '/home/project',
    get_include_path()
));