switch(false) {
case 'blogHitd':
echo('ddd');
break;
case false:
echo('bbbb');
break;
default:
echo 'alert("error action");';
}
——-output——
bbbb
switch(true) {
case 'blogHitd':
echo('ddd');
break;
case true:
echo('bbbb');
break;
default:
echo 'alert("error action");';
}
——-a strange output——-
ddd
Why, when I pass the value of true it will always select the first one?
From the PHP documentation on Booleans:
The last sentence of this quoted passage is the line of interest in your case.