【发布时间】:2014-01-17 12:26:47
【问题描述】:
这是我的目录树:
- /
- index.php
- 包括/
- functions.php
- head.php
- connect.php
- 子/
- index.php
在我的 head.php 和 connect.php 中都有:
include_once 'include/functions.php';
我的根目录下的index.php包含这两个:head.php和connect.php,如下:
include_once 'include/connect.php';
include_once 'include/head.php;'
但是,当我在 sub/ 中的 index.php 包含 functions.php 和 head.php 时,它们将无法同时包含 functions.php。 这是我在 sub/index.php 中包含的方式:
include_once '../include/connect.php';
include_once '../include/head.php';
如果我将 head.php 和 connect.php 更改为:include_once '../include/functions.php';
sub/index.php 将正常包含所有内容,但根目录中的 index.php 将无法加载 functions.php。
我该如何解决这个问题?
PHP 版本:5.2.*
【问题讨论】:
-
我认为您的
head.php和connect.php包含语句中有错误。include_once 'include/functions.php';应该是include_once 'functions.php';因为head.php 和connect.php 与functions.php 在同一个目录中?如果我错了,请纠正我:P -
@vincent-wilkie 谢谢!这就是它一直遇到的问题...谢谢!
标签: php