PHP:警告:包括未能在 Windows 上打开流没有这样的文件或目录

2022-01-25 00:00:00 include php

我在 Windows 上的 xampp 上运行的 PHP 脚本中有一个 include 语句.如果我使用相对路径:

I have an include statement in a PHP script running on xampp on Windows. If I use a relative path :

include '../config/eventInfoConfig.php';  

我收到错误消息:

警告:include(../config/eventInfoConfig.php) [function.include]:打开流失败:没有这样的文件或目录

Warning: include(../config/eventInfoConfig.php) [function.include]: failed to open stream: No such file or directory

但是如果我使用绝对路径我没有错误:

But if I use the absolute path I have no error:

include 'c:/xampp/htdocs/xampp/appTrials/myApp/config/eventInfoConfig.php'; 

如何在我的包含中使用相对路径而不导致错误?

How can I use a relative path in my include without causing an error?

推荐答案

修复 include_path() 以包含正确的路径就可以了.

Fixing the include_path() to include the right path does the trick.

相关文章