Pergunta

What is the difference between between:

!isset($value1) && !isset($value2)

and

!isset($value1, $value2)

? Thanks.

Foi útil?

Solução

In the first case both variables need to not be set for the entire condition to be true.

In the second case, either variable not being isset, will cause the condition to be true.

Is this some sort of test question?

Outras dicas

The first one is true if both variables not set. The second one is true if any or both variables are not set.

You can look at it as a logic expression and apply some laws of logic.

!isset($value1, $value2) can be rewritten as !(isset($value1) && isset($value2)) (we know it from the PHP manual). Then you can use De Morgan's law and rewrite it as !isset($value1) || !isset($value2).

Now they're easier to compare:

!isset($value1) || !isset($value2)
!isset($value1) && !isset($value2)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top