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 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行