duanla4959 2014-09-23 23:51
浏览 148
已采纳

正确使用AND OR(|| &&)和两个字符串值

I could not find the answer to this anywhere, and it's a newbee mistake. Can someone help me with this statement:

<?php 
if ($db_ownrPlan == 'sell in a year or so' || 'get some info only no plans made yet'){
    echo "$TYmessage";
} elseif ($db_ownrPlan == 'sell soon' || 'sell in 3 to 6 months' || 'looking to buy this property'){
    echo "$TYmessage1";
} else {
    echo "$TYmessage2";
} 
?>
  • 写回答

3条回答 默认 最新

  • donglin9717 2014-09-23 23:52
    关注

    This is what you want to do:

    <?php 
    if ($db_ownrPlan == 'sell in a year or so' || $db_ownrPlan == 'get some info only no plans made yet'){
        echo "$TYmessage";
    } elseif ($db_ownrPlan == 'sell soon' || $db_ownrPlan == 'sell in 3 to 6 months' || $db_ownrPlan == 'looking to buy this property'){
        echo "$TYmessage1";
    } else {
        echo "$TYmessage2";
    } 
    ?>
    

    In PHP, and most other programming languages with similar syntax, you would compare variables like this:

    VAR == value OR VAR == otherValue
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大