doukucai0099 2018-02-15 09:39
浏览 1192
已采纳

PHP警告:include():打开失败

I have this error on my site after I moved it from a shared hosting to a VPS (both with cPanel).

PHP Warning: include(): Failed opening '../../../transporturi/a.php' for inclusion (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in [...] on line 36.

In the other file on line 36 I have included a PHP file, I checked the path and it's there. I also tried to switch PHP version from the WHM from 5.5 to 5.6 to 7.0, but no luck.

  • 写回答

1条回答 默认 最新

  • dongsheng4679 2018-02-15 09:51
    关注

    The path is relative to the file that received the request, so you can use the PHP DIR magic constant to know what is your current directory:

    echo(__DIR__);
    

    and then form the absolute path relative to your file as below.

    include(__DIR__ . '../../../transporturi/a.php');
    

    Now it depends on your directory structure and the location of both the included file and the one where its included.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?