我遇到了set_include_path的问题,我读了很多关于这个问题的消息,但没有一个对我有用.我在Debian上,我的根目录将设置为/ home/project /
所以我尝试了这4种不同的东西:
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');
Run Code Online (Sandbox Code Playgroud)
但没有一个...当我做回声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
Run Code Online (Sandbox Code Playgroud)
尝试使用PATH_SEPARATOR常量,就像在文档中一样.
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
Run Code Online (Sandbox Code Playgroud)
也许它在您将应用程序部署到的系统上有所不同.
更新:包含路径似乎很好,但问题是不同的..
你不应该包括:
require '/config/config.php'
Run Code Online (Sandbox Code Playgroud)
但
require 'config/config.php'
Run Code Online (Sandbox Code Playgroud)
因此,删除前导斜杠,它应该工作.
| 归档时间: |
|
| 查看次数: |
2381 次 |
| 最近记录: |