Re: alter switch variable inside case?
| From: | CHAILLAN Nicolas | Date: | Sun, 01 Sep 2002 00:10:57 +0000 |
| Subject: | Re: alter switch variable inside case? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-114798@lists.php.net to get a copy of this message | ||
Yes you can.
--
Merci de nous avoir choisi. - Thanks you for your choice.
Nicos - CHAILLAN Nicolas
nicos@worldakt.com
nicos@php.net
www.GroupAKT.com - Hébergement Group.
www.WorldAKT.com - Hébergement de sites Internet
"Joe Janitor" <joe_janitor@yahoo.com> a écrit dans le message de news:
20020831181245.45286.qmail@web10803.mail.yahoo.com...
> I'd like to be able to modify the switch variable inside a case
> statement, like this:
>
> switch ($foo) {
> case 'step2':
> do_step2();
> if ($error) $foo='step1'; //repeat step1
> break;
>
> case 'step1':
> do_step1();
> break;
>
> case 'a_third_thing':
> do_something_else();
> break;
> }
>
> Can you modify the variable ($foo) inside a case statement and
> have it evaluated for subsequent 'case's like this? If not, I
> will have to revert to a series of if statements, in which this can
> be done:
>
> if ($foo=='step2') {
> do_step2();
> if ($error) $foo='step1';
> }
> if ($foo=='step1') {
> do_step1();
> }
> etc.
>
> Switch-case seems cleaner, and I'd prefer to stick with it.
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Finance - Get real-time stock quotes
> http://finance.yahoo.com