1

我在本地运行一个网站。

我有一个主文件夹,其中包含普通用户的所有主要编码,它是一个名为main.php.

在这个主文件夹中,我有另一个管理员文件夹,其中包含例如名为announcement2.php. 但是,当我尝试将其包含在首页(index.php)中时,会出现错误,就像服务器无法读取 admin 文件夹内的文件一样。

错误是:

Warning: include(../admin/announcement2.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\pods\main.php on line 85

Warning: include() [function.include]: Failed opening '../admin/announcement2.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\pods\main.php on line 85

这是将文件包含在管理文件夹中的代码main.php

<td><?php include '../admin/announcement2.php'; ?></td>
4

1 回答 1

2

This probably just means either (a) permissions are incorrect (web server can't read the file), or more likely, (b) the path is incorrect. If you echo $_SERVER['PHP_SELF']; you'll see the path of the script, which would shed light on what path to actually use. But it's usually faster to try a few variations ...

include '../admin/announcement2.php';
include 'admin/announcement2.php';
include '../../admin/announcement2.php';

... until something works.

于 2012-08-01T04:14:57.433 回答