set_include_path函数不起作用,PHP 5.2.13

时间:2011-12-01 14:19:11

标签: php roundcube set-include-path

我们在公司使用VPS服务器而且我正在尝试安装Roundcube webmail界面

但我甚至无法进入配置阶段,因为set_include_path函数不起作用,脚本无法找到所需的配置文件。

我收到类似“致命错误,ini_set / set_include_path函数不起作用”的错误。

我假设某些php设置导致了这一点,但我不知道哪一个。

如果能得到一些帮助,我会很高兴。

提前致谢

//编辑以下是脚本中的代码

ini_set('error_reporting', E_ALL&~E_NOTICE);
ini_set('display_errors', 1);

define('INSTALL_PATH', realpath(dirname(__FILE__) . '/../').'/');
define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');

$include_path  = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
$include_path .= INSTALL_PATH . 'program' . PATH_SEPARATOR;
$include_path .= INSTALL_PATH . 'program/include' . PATH_SEPARATOR;
$include_path .= ini_get('include_path');

set_include_path($include_path);

require_once 'utils.php';
require_once 'main.inc';

1 个答案:

答案 0 :(得分:0)

我是从内存中执行此操作,因此可能不太正确,但我想您可能会混淆路径和目录分隔符。还有一种比你正在做的更好的方法(即一次组装整个路径)。尝试这样的事情:

define('INSTALL_PATH', dirname(dirname(__FILE__)));

set_include_path(get_include_path() . PATH_SEPARATOR . INSTALL_PATH . DIRECTORY_SEPARATOR . 'program' . DIRECTORY_SEPARATOR . 'lib'); set_include_path(get_include_path() . PATH_SEPARATOR . INSTALL_PATH . DIRECTORY_SEPARATOR . 'program' . DIRECTORY_SEPARATOR . 'include'); set_include_path(get_include_path() . PATH_SEPARATOR . INSTALL_PATH . DIRECTORY_SEPARATOR . 'program');

通常我会使用implode压缩这一点,因为DIRECTORY_SEPARATOR非常冗长:

...PATH_SEPARATOR . implode(DIRECTORY_SEPARATOR, Array(INSTALL_PATH, 'program', 'lib'));

我认为(最重要的是)将一些PATH更改为DIRECTORY,并且(可能)使用增量get_include_pathset_include_path调用,它将更具可读性,可移植性并且可能正常工作。