PHP set_include_path 配置

标签 php linux debian

我遇到了 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');

但是没有任何效果...当我执行 echo get_include_path(); 时每次看起来都不错。

但是第 4 种方法在我的计算机上与 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

最佳答案

按照文档中的说明尝试使用 PATH_SEPARATOR 常量。

set_include_path(get_include_path() . PATH_SEPARATOR . $path);

也许它因您要部署应用程序的系统而异..

更新: 包含路径似乎没问题,但问题有所不同..

你不应该包括:

require '/config/config.php'

但是

require 'config/config.php'

所以去掉前导斜线,它应该可以工作。

关于PHP set_include_path 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8474008/

相关文章:

php - fseek() 逐行,而不是字节?

linux - 什么是 .sh 文件?

linux - Debian wheezy 上的括号 Sprint 40

php - 如何获取PHP查询的返回值

php - 使用 php 从 MySql 数据库中检索印度语言数据显示异常字符集

Linux - 网络配置

linux - rc.local 似乎没有在首次启动时运行

docker - 从用户 github 源设置容器

php - 如何使用 Laravel Eloquent 添加过滤器和分页

linux - 是否有适用于 Linux 的 WinSCP?