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

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.

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

报告相同问题?

悬赏问题

  • ¥15 MFC平台生成指定圆
  • ¥15 jmeter出现403
  • ¥500 求华为P30PRO手机硬盘数据恢复
  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关
  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题
  • ¥60 基于JTag协议开发Fpga下载器上位机,哪位大🐂有偿指导?
  • ¥20 全书网Java爬取数据