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