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) {
I just use
$var === null and $var = -1; // since switch is not type-safe
switch ( $var ) {
case 0:
# this tests for zero/empty string/false
break;
case -1:
# this tests for null
break;
}
I think this still looks very readable if the comment starting with // is left behind (and the ones starting with # are probably best deleted).