且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法打开流:在该目录中没有这样的文件或目录

更新时间:2022-06-15 23:13:14

这是因为您在文件路径中包含了前导/. /使其从文件系统的顶部开始.注意:文件系统路径,而不是网站路径(您不会通过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.