Posted by Pedro Graca on 10/23/06 00:17
Juliette wrote:
> Pedro Graca wrote:
>> When there is no match for the case expressions and there are several
>> `default` cases (illegal in C too), the one chosen seems to be the last
>> and not, as I expected, the first.
>
> No matter what, having several 'default:' cases is *always* highly
> inadvisable.
SCNR
Having several `case CONSTANT:` with the same CONSTANT is ok? :)
<?php
$var = true;
echo "First set: ";
switch ($var) {
default: echo 'No variables in the list are'; break;
case isset($a): echo 'a is'; break;
case isset($b): echo 'b is'; break;
case isset($c): echo 'c is'; break;
case isset($d): echo 'd is'; break;
}
echo " set.\n";
$b = $c = 42;
echo "Second set: ";
switch ($var) {
default: echo 'No variables in the list are'; break;
case isset($a): echo 'a is'; break;
case isset($b): echo 'b is'; break;
case isset($c): echo 'c is'; break;
case isset($d): echo 'd is'; break;
}
echo " set.\n";
?>
To the Original Poster: don't use this code!
--
I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.
[Back to original message]
|