我阅读了其他一些相关问题,并认为这是最好的答案:
set_include_path(get_include_path().PATH_SEPARATOR."/path/to/program/root");
但是,我无法将它放到正确的目录中,并且错误消息也没有足够的帮助,所以我迷路了。我的用户区目录(共享主机)如下所示:
/home/linweb09/b/example.com-1050560306/user # <-- this is my root
我试图重新组织我的程序,以便所有模型文件都放在这个目录中:
{root}/program_name/library/
web-root 文件夹是这样的:
{root}/htdocs/
因此,我将所有包含更改为如下所示:
set_include_path(get_include_path().PATH_SEPARATOR
."/home/linweb09/b/example.com-1050360506/user");
require_once "/program_name/library/some_module.php";
索引必须加载此包含才能工作,以验证用户:
/htdocs/admin/authenticate.php
# index.php
set_include_path(get_include_path().PATH_SEPARATOR
."/home/linweb09/b/example.com-1050360506/user");
require_once "/htdocs/admin/authenticate.php";
我遇到了这些错误:
[警告] mod_fcgid: stderr: PHP 致命错误:
require_once() [function.require]: 无法打开所需的 '/htdocs/admin/authenticate.php'
(include_path='.:/usr/share/pear:/usr/share /php:/home/linweb09/b/example.com-1050360506/user')
在 /home/linweb09/b/example.com-1050360506/user/htdocs/admin/index.php 第 3 行[警告] mod_fcgid:stderr:PHP 警告:
require_once(/htdocs/admin/authenticate.php) [function.require-once]:无法打开流: /home/linweb09/b/example.com
中没有这样的文件或目录
-1050360506/user/htdocs/admin/index.php 在第 3 行
但它在正确的位置,错误说没有这样的文件或目录,所以我不确定我应该如何配置它。
我也试过这些,我得到了同样的错误:
set_include_path(get_include_path().PATH_SEPARATOR."/user");
set_include_path(get_include_path().PATH_SEPARATOR."/");