【发布时间】:2016-12-20 10:48:44
【问题描述】:
这是我的php文件结构:
练习-php
- index.php
- 型号
- model.php
- 连接器
- connectionUtility.php
在模型 php 中我写: 包括'../connector/connectionUtility.php'; 在 index.php 中 包括'model/model.php';
当我运行“model.php”时,没有任何错误,但是当我运行“index.php”时,浏览器显示:
require(../connector/connectionUltility.php):打开流失败:C:\wamp64\www\php-practice\model\model.php 中没有这样的文件或目录
致命错误:require():在 C:\wamp64\www\php-practice\model 中打开所需的 '../connector/connectionUltility.php' (include_path='.;C:\php\pear') 失败\model.php
我找到了我的问题的答案。如果我写: 在“model.php”中包含“connector/connectionUtility.php”,那么我只需要在“index.php”中包含“model.php”。系统仍然会理解。
感谢大家的帮助。
【问题讨论】:
-
使用完整路径而不是相对路径通常可以解决此类问题。即:
include( $_SERVER['DOCUMENT_ROOT'] . '/connector/connectionUltility.php' );或使用set_include_path之前使用include -
@ Ilaya Raja S 当你输入
..时,它会返回一个文件夹,所以在index.php中它会尝试从www方向包含它
标签: php