dto52236 2014-04-11 15:01
浏览 44
已采纳

require_once无法在实时服务器上运行

I have a situation where a php line is working fine on localhost but not on live server, even if I have the same file and folder structure.

require_once '/../Renderer.php';

The error I am getting on live server is:

Warning: require_once(/../Renderer.php): failed to open stream: No such file or directory in /home2/attafsir/public_html/balaghatoalquran/production/wp-content/themes/twentyten/Text/Diff/Renderer/unified.php on line 19

Fatal error: require_once(): Failed opening required '/../Renderer.php' (include_path='.:/usr/php/54/usr/lib64:/usr/php/54/usr/share/pear') in /home2/attafsir/public_html/balaghatoalquran/production/wp-content/themes/twentyten/Text/Diff/Renderer/unified.php on line 19

I have spend a lot of time trying to figure out what could be the reasons behind such behaviour, but to no avail, your help is appreciated.

PS: I have verified with my host if PEAR is installed and configured in php.ini, and they confirm it to me. (since the code is using PEAR package)

Solution: The solution is the accepted answer, but I want to notice though that the problem on live server is resolved but broke the functionning on localhost. This is a temporary solution since the best thing is to have the same code on local and live server. I will be back to post a full solution when I find it. your suggestion are always welcome.

  • 写回答

4条回答 默认 最新

  • dongtaidai0492 2014-04-11 15:02
    关注

    / is the root of the file-system and then you try to go up one level with ... That does not exist so you get an error.

    Are you sure you do not want a relative path?

    If you want it to be relative to the root of the web-server (which is not the root of the file-system unless there is something very wrong), use something like:

    $_SERVER['DOCUMENT_ROOT'] . '/../Renderer.php'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作