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

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.

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

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大