Hi Andi,
It might be documented but it has not always been working like this. I
have some code that I have not touched for over 2 years, and It has workd
with both PHP4 and PHP5 versions (even PHP5-1-0-dev from Aug 19 2004
17:03:39 ). After upgrading to PHP5 CVS-HEAD it stopped working.
I have no problem forcing the default: to the buttom, but as the behavior
of PHP changd I just wanted to know if it was intentional or a bug.
In my case I hace a long �ist of case 1, case 2 etc. and the default case
was the first so I had that on the top of thie list to keep a nice order.
- Frank
> It's always been like that and has been documented for ages in the
manual.
>
> Andi
>
> At 08:24 PM 10/7/2004 -0700, Frank M. Kromann wrote:
> >Hello Everyone,
> >
> >I just discovered a small thing in the switch() statement. The position
of
> >the default: clause has to be at the end of the code:
> >
> >$a = 1;
> >switch ($a) {
> > default :
> > case 0 :
> > $b = 1;
> > break;
> > case 1 :
> > $b = 2;
> > break;
> >}
> >echo $b; // should print 2 but it prints 1
> >
> >$a = 1;
> >switch ($a) {
> > case 1 :
> > $b = 2;
> > break;
> > default :
> > case 0 :
> > $b = 1;
> > break;
> >}
> >echo $b; // prints 2 as expected.
> >
> >This is tested on Linux with PHP5 CVS-HEAD
> >
> >What changed ?
> >
> >- Frank
> >
> >
> >
> >
> >
> >--
> >PHP Internals - PHP Runtime Development Mailing List
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php