dqq46733 2013-03-25 16:08
浏览 22
已采纳

解析错误:语法错误,意外':'

Why am I getting this error the code works on the live demo the developer shows and its the same code? Any help would be most appreciated.

$method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ?: $_SERVER['REQUEST_METHOD'];
  • 写回答

2条回答 默认 最新

  • douruye5092 2013-03-25 17:48
    关注

    The problem is not with the fact that the ternary operator is missing an argument as other stated. The problem is probably the PHP version of the server.

    Straight from the PHP doc :

    Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise.

    The way it is written is valid for any server with PHP version equal or above to 5.3.

    Else it should be re-written in its equivalent expression :

    $method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ?  $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] : $_SERVER['REQUEST_METHOD'];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?