Re: Using strings in switches
| From: | Justin Garrett | Date: | Wed, 06 Feb 2002 06:52:04 +0000 |
| Subject: | Re: Using strings in switches | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-83677@lists.php.net to get a copy of this message | ||
Try it.
But to answer your question, yes. Don't forget to put quotes around your
strings in the case statements.
switch($name){
case "beesly":
break;
}
"Phantom" <phantom@phantomcougar.com> wrote in message
news:3C60CFA9.367D27CC@phantomcougar.com...
> The manual shows that you can use switches with numeric values but is it
> also possible to use strings? Is this possible? If not, what can I
> do? Just a bunch of if statements?
>
> <?
> if (isset($Name)) {
> switch ($Name)
> case Homer Simpson:
> echo "DO'H!!!!<p>";
> break;
> case Fred Flinstone:
> echo "Yabba Dabba Do<p>";
> break;
> default:
> echo "Do not know you<p>";
> break;
> }
> }
> ?>
>