无法打开流:没有这样的文件或目录
> 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 时会出现该错误:
include_once("/PoliticalForum/headerSite.php");
> 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
Why do I get that Error when I use include_once:
include_once("/PoliticalForum/headerSite.php");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是因为您在文件路径中包含了前导
/
。/
使其从文件系统的顶部开始。注意:文件系统路径,而不是网站路径(您不是通过 HTTP 访问它)。您可以将相对路径与include_once
(不以前导/
开头的路径)结合使用。您可以将其更改为:
这将首先在包含它的文件所在的目录中查找(即示例中的 C:\xampp\htdocs\PoliticalForum\ )。
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 withinclude_once
(one that doesn't start with a leading/
).You can change it to this:
That will look first in the same directory as the file that's including it (i.e.
C:\xampp\htdocs\PoliticalForum\
in your example.include() 需要相对于文件系统根目录的完整文件路径。
这应该有效:
include() needs a full file path, relative to the file system's root directory.
This should work:
你可以使用:
you can use:
由于给定的路径错误而发生无法打开流错误,例如:
如果图像文件夹不允许您存储图像,则会出现错误,
确保您的文件夹可读
Failed to open stream error occurs because the given path is wrong such as:
It will give an error if the images folder will not allow you to store images,
be sure your folder is readable