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 对于这个问题的代码运行
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败