PHP If语句条件不起作用 [英] PHP If Statement conditions not working

查看:129
本文介绍了PHP If语句条件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

if($InboundTextBody === 'Help' OR 'help'){
   echo 'help';
} 
elseif($InboundTextBody === 'Reset'){
      echo 'send reset message';
}
elseif($InboundTextBody === 'Start'){
       echo 'send start message';
}

if($InboundTextBody === 'Help' || 'help'){
   echo 'help';
} 

如果我的$ InboundTextBody带有帮助一词.它将回显帮助.如果$ InboundTextBody具有单词Reset,它仍会回显帮助.它从不回声重置. 我需要在语句中使用或,以防$ InboundTextBody文本为大写或小写文本

If my $InboundTextBody has the word Help. It will echo Help. If the $InboundTextBody has the word Reset it still echo help. it never echo reset. I need the or in my statement just in case the $InboundTextBody text has up case or lower case text

推荐答案

IF的正确语法是

if($InboundTextBody === 'Help' OR $InboundTextBody === 'help'){

或者您可以将所有内容都转换为小写并做

Or you could convert all to lowercase and do

if(strtolower($InboundTextBody) === 'help'){

这篇关于PHP If语句条件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆