switch strange behavior with comparision
Posted: Wed May 26, 2010 7:31 am
Hi there...
Here's a small snippet of PHP code:
this code allways returns "case1". isn't that wrong?
i allways thought that it should return "default". It does so if $var1 is one or two or something like that but not with zero..
Thanks for your ideas!
Here's a small snippet of PHP code:
Code: Select all
$var1 = 0;
$var2 = 5;
switch($var1)
{
case ($var1 >= $var2):
echo 'case1';
break;
case 5:
echo 'case2';
break;
default:
echo 'default';
break;
}i allways thought that it should return "default". It does so if $var1 is one or two or something like that but not with zero..
Thanks for your ideas!