문제

What is the difference between between:

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

and

!isset($value1, $value2)

? Thanks.

도움이 되었습니까?

해결책

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?

다른 팁

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top