doupang5433 2017-02-16 11:10
浏览 103
已采纳

PHP if语句&&逻辑运算符错误

I hope this question hasn't been asked yet.

Time to time I get into the same problem while I'm coding, which is when I'm using two or more && logical operators like this:

if ($sCategory['sub_category_name'] == $subCat && $action == 'edit') {
    //Do stuff here
}

I get the error:

PHP Parse error: syntax error, unexpected '$action' (T_VARIABLE)

As reading some of other topics, I saw that sometimes there are hidden characters which cause the problem, but I did not find any other solution to mine. I'm using Sublime Text 3 on an iMac.

Thanks in advance

  • 写回答

1条回答 默认 最新

  • doule0941 2017-02-16 11:32
    关注

    Please try this:

    According to me, the array value is creating issue, so take this array value in another variable, just like this:

    $cat_val = $sCategory['sub_category_name'];
    if (($cat_val == $subCat) && ($action == "edit")) {
        //Do stuff here
    }
    

    Please try it once.

    Hope, it may be helpful to you.

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

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序