PHP IF函数检查多个语句/参数


PHP IF function checking more than one statement/argument

当一个人想要检查多个语句/参数时,在PHP中使用if()函数的最佳实践是什么?

示例:

if ( isset($string) && empty($string2) {
 code
}

应该改为:

if ( (isset($string)) && (empty($sting2)) ) {
 code
}

在您的示例中,我不会使用第二组括号。

当条件逻辑有点复杂时,需要额外的括号,例如:

if ( (isset($string) || isset($strstr)) && empty($sting2) ) {
  code
}