【问题标题】:set_include_path sets path but path doesn't workset_include_path 设置路径但路径不起作用
【发布时间】:2016-10-20 00:35:52
【问题描述】:

我已经阅读了几乎所有关于 set_include_path 的帖子,但我还没有找到我真正理解的帖子。

我正在尝试使用 UserSpice 在新网站上登录。当然,我已经有了该站点的文件结构,我想我可以简单地将 UserSpice 文件夹添加到该结构中,然后使用 set_include_path 访问 UserSpice 中的所有文件。但我想我只是不了解一般的功能或路径。

这是我的代码: set_include_path(get_include_path() . PATH_SEPARATOR . 'C:\xampp\htdocs\mynewsite\userSpice');

这是结果: 致命错误:require_once():在 E:\xampp\ 中打开所需的 'users/init.php' (include_path='.;C:\xampp\php\PEAR;C:\xampp\htdocs\mynewsite\userSpice') 失败htdocs\mynewsite\index.php 第 10 行

“users”文件夹是“mynewsite/userSpice”的子文件夹,所以我认为该路径将允许访问该文件夹。

谁能帮忙?

【问题讨论】:

  • 可能是权限问题。
  • UserSpice 的所有路径都基于 z_us_root 文件所在位置。它是文件系统中的灯塔,一切都从那里开始。

标签: php


【解决方案1】:

您必须使用$_SERVER['DOCUMENT_ROOT'] 才能访问所需的路径:

require_once $_SERVER['DOCUMENT_ROOT'] .'/mynewsite/userSpice/users/init.php';

require_once $_SERVER['DOCUMENT_ROOT'] .'/mynewsite/userSpice/users/includes/header.php';

require_once $_SERVER['DOCUMENT_ROOT'] .'/mynewsite/userSpice/users/includes/navigation.php';

【讨论】:

    猜你喜欢
    • 2023-02-21
    • 2018-01-10
    • 1970-01-01
    • 2013-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-27
    相关资源
    最近更新 更多