【发布时间】:2013-02-19 11:36:00
【问题描述】:
我的文件结构如下:
>project
>admin
>classes
>class_main.php
>templates
>foot.php
在 class_main.php 中,我尝试使用 require_once 来要求相同的文件,这取决于用户所在的位置(即,如果用户在管理目录中,则 require_once "../templates/foot.php" 否则 require_once "./templates/foot.php")我班级的 __destruct 函数。
我的问题是,无论我尝试什么,我总是收到相同的错误:
警告:require_once(C:\wamp\www\project\classes/templates/foot.php) [function.require-once]:无法打开流:C:\wamp\www\ 中没有这样的文件或目录project\classes\class_main.php 在第 22 行
我试过了:
- 使用 require_once 作为函数
- 使用
dirname(__FILE__)和__DIR__ - 使用
\和\\而不是/
我该怎么做?
此刻__destruct函数的完整代码为:
function __destruct()
{
if($this->admtrim($_SERVER['PHP_SELF']) == 'admin')
{
require_once "../templates/foot.php";
}
else
{
require_once './templates/foot.php';
}
}
为了澄清,这个脚本位于C:\wamp\www\project\classes\class_main.php,我试图包含的文件位于C:\wamp\www\project\templates\foot.php。
【问题讨论】:
-
如果您想要一些有用的答案,请使用
require_once发布实际代码。
标签: php require-once