php if if条件基于|| &安培;&安培;如何根据给定值显示消息

时间:2017-12-13 11:48:21

标签: php if-statement

$ status变量可以是“待定”或“已批准” 我如何应用标准的php if else条件与OR(||)AND(&&)显示如下

If the $status are **both** pending and approved:  display **pending** message
If all $status are pending: display **pending** message 
If all $status are approved: display **approved** message

如何使用php

基于给定参数显示消息

例如:

if(($request->is_approved ==1  && $request->is_approved ==2)){
//echo pending
}
elseif(($request->is_approved ==1  && $request->is_approved !=2)){
// echo pending
}
else(($request->is_approved !=1  && $request->is_approved ==2)){
//echo approved
}

1 个答案:

答案 0 :(得分:0)

//if status is array
if($status['pending'] == true && $status['approved'] == true) {
   //do something
}
else if($status['pending'] == true) {
    //do something
}
else if($status['approved'] == true) {
   //do something
}
else {
   //do something
}

此外,状态可以是一个字节,所以

if $status == 1 its approved,   
if $status == 2 its pending,  
if $status == 3 its approved and pending,  
if $status == 0 its not approved and not pending.