Given this:
$ids = '';
I just realized that this:
$single = $ids == FALSE || is_array($ids)? FALSE : TRUE;
var_dump($single);
and this:
if ($ids == FALSE)
{
$single = TRUE;
}
else
{
if (is_array($ids))
{
$single = FALSE;
}
else
{
$single = TRUE;
}
}
var_dump($single);
Display different results (false and true respectively). However, This only happens when the variable is:
$ids = '';
or
$ids;
If $ids is an array, an integer, or a string it works fine.
Does anybody know why? Thanks in advance!
By the way, I have just realized that if you type $ids === FALSE in the first conditional stament (the single line one) it will work fine. But I still don’t understand the ‘logic’ behind this.
You forgot parentheses:
Live demo.
Without them, precedence gives you a result different from that which you were expecting:
Note that
'' == FALSEistrue; I’m not sure whether you realised that.