[英]How to use AND/OR in if else PHP statement
how to shorting the codes 如何缩短密码
if(stristr($A,'Erorr Email')){
echo 'Error Login';
}
elseif(stristr($A,'Erorr Password')){
echo 'Error Login';
}
i want add 'AND' to If and delete 'elseif' .. 我想将'AND'添加到If并删除'elseif'..
If you use AND
both the statements must be true ie $A should be equal to Erorr Email
and Erorr Password
which is not correct and not possible. 如果使用
AND
两个语句都必须为true,即$ A应等于Erorr Email
和Erorr Password
,并且是不可能的。
You have to use OR
. 您必须使用
OR
。 So that if any one of the statement is true then it enters into the loop. 这样,如果任何一条语句为true,则它会进入循环。
if(stristr($A,'Erorr Email') || stristr($A,'Erorr Password')){
echo 'Error Login';
}
or 要么
if(stristr($A,'Erorr Email') or stristr($A,'Erorr Password')){
echo 'Error Login';
}
http://php.net/manual/en/language.operators.logical.php http://php.net/manual/zh/language.operators.logical.php
if(stristr($A,'Erorr Email') || stristr($A,'Erorr Password')){
echo 'Error Login';
}
And read this link to learn more: PHP Operators 并阅读此链接以了解更多信息: PHP运算符
if(stristr($A,'Erorr Email') || (stristr($A,'Erorr Password')){
echo 'Error Login';
}
OR sample 或样品
if(stristr($A,'Erorr Email') || (stristr($A,'Erorr Password')){
echo 'Error Login';
}
AND sample AND样本
if(!(!stristr($A,'Erorr Email') && !stristr($A,'Erorr Password'))){
echo 'Error Login';
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.