PHP 调用相对路径出错 failed to open stream: No such file or directory
    文章作者:恒爱网络 阅读次数:2842 发布时间:2021-7-9

    PHP很多程序有习惯调用相对路径的情况,譬如 

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

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

    以前没怎么注意过,今天换了环境之后突然发现之前运行正常的程序,一直报  failed to open stream: No such file or directory

    看来是无法调用相对路径导致的,经过对比,发现在PHP.ini 配置文件里 ,如果启用 fastcgi.impersonate =1 那么相对路径的调用就正常了。

    注意修改后要重启WEB服务器重新加载PHP哦。