我有4个变量。
我该怎样做?
$x1='on';
$x2='';
$x3='';
$x4='';
if $x1=='on' and $x2 is empty and $x3 is empty and $x4 is empty , do this else do that ?
答案 0 :(得分:0)
像这样:
if($x =='on' && $x2 =="" && $x3 == "" && $x4 == ""){
}else{
}
将来参考PHP手册和这里的表达操作符链接: http://php.net/manual/en/language.operators.logical.php
答案 1 :(得分:0)
或者,您可以使用空命令,如下所示:
if($x =='on' && empty($x2) && empty($x3) && empty($x4)){
}
else{
}