Nope. From the manual page:
Note that switch/case does loose comparison.
If you only have two conditions, use an if
like your second example. Otherwise, check for NULL
first and switch on the other possibilities:
if (is_null($var))
{
return 'a';
}
switch ($var)
{
// ...
}