【发布时间】:2014-09-05 09:16:14
【问题描述】:
我一直在讨论这两个主题:
- include, require and relative paths
- PHP - with require_once/include/require, the path is relative to what?
并且无法使我的脚本工作,所提供的方法都不起作用,或者我做错了什么。
无论如何,这就是我的问题发生的地方:
Root/ //this is root location for server
APP/ //this is root location for script
Root/APP/core/init.php //this is where I include classes and functions from
Root/APP/classes/some_class.php //this is where all classes are
Root/APP/functions/some_function.php //this is where all functions are
显然我需要在任何地方都包含init.php,所以我在每个文件中都这样做了:
require_once 'core/init.php';
在我决定为这样的管理文件创建一个位置之前,它一直在工作:
Root/APP/Admin/some_admin_file.php
当我以这种方式包含 init 时:
require_once '../core/init.php';
脚本无法打开函数,APP/Core/ 文件夹中没有此类文件
所以我使用了上面主题中介绍的 DIR 方法,甚至发生了更奇怪的事情,错误:
APP/Core/classes/Admin/中没有这样的文件
那是什么? :D 我迷路了,有人能帮忙吗;)
【问题讨论】:
-
检查字母的大小写,它们是这样大写的: APP/Core/ 或 APP/core/ ,其中一个是错误的
标签: php