无法打开流:在该目录中没有这样的文件或目录 [英] failed to open stream: No such file or directory in

查看:367
本文介绍了无法打开流:在该目录中没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>     Warning: include_once(/PoliticalForum/headerSite.php) [function.include-once]: failed to open stream: No such file or
> directory in C:\xampp\htdocs\PoliticalForum\mainHome.php on line 16
> 
> Warning: include_once() [function.include]: Failed opening
> '/PoliticalForum/headerSite.php' for inclusion
> (include_path='.;C:\xampp\php\PEAR') in
> C:\xampp\htdocs\PoliticalForum\mainHome.php on line 16

为什么当我使用include_once时会出现该错误:

Why do I get that Error when I use include_once:

   include_once("/PoliticalForum/headerSite.php");

推荐答案

这是因为您在文件路径中包含了前导/. /使其从文件系统的顶部开始.注意:文件系统路径,而不是网站路径(您不会通过HTTP访问它).您可以在include_once中使用 relative 路径(该路径不以前导/开头).

It's because you have included a leading / in your file path. The / makes it start at the top of your filesystem. Note: filesystem path, not Web site path (you're not accessing it over HTTP). You can use a relative path with include_once (one that doesn't start with a leading /).

您可以将其更改为此:

include_once 'headerSite.php';

它将首先在与包含该文件的文件相同的目录中查找(例如,在您的示例中为C:\xampp\htdocs\PoliticalForum\.

That will look first in the same directory as the file that's including it (i.e. C:\xampp\htdocs\PoliticalForum\ in your example.

这篇关于无法打开流:在该目录中没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆