Is there anyway to make it so that the following code still uses a switch and returns b
not a
? Thanks!
$var = 0;
switch($var) {
case NULL : return 'a'; break;
default : return 'b'; break;
}
Using if statements, of course, you'd do it like this:
$var = 0;
if($var === NULL) return 'a';
else return 'b';
But for more complex examples, this becomes verbose.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…