什么';s嵌套条件语句的语法


What's the syntax for nested conditional statements?

我想检查$AD=1是否存在,如果没有传递给另一个函数,但如果$AD=1,请检查AC=是否包含一些值,如果没有,请执行一些操作。

if ($AD == '1'){
if ($AC == ''){
echo 'AC is empty';
} else { 
///////Function/////
}
}

谢谢。

else if语句必须始终与同一"嵌套级别"上的起始if语句相对应。

您的内部else if没有任何开始的if语句,因此它失败了。

if ($AD == 1) {
  if ($AC == '') {
    echo 'empty';
  }
}
else {
  otherFunction($AD);
}

由于这是基本的PHP(实际上IF大多不依赖于语言),我建议您阅读初学者教程。

if ($AD == 1){
  if ($AC == ''){
    // some code where ac has the value
   } else {
     // some code where ac doesn't have the value
   }
 } else  {
   // other function
 }

这应该可以做到