You are here: Re: Switch isset and $_get « PHP Programming Language « IT news, forums, messages
Re: Switch isset and $_get

Posted by Juliette on 10/22/06 21:41

Pedro Graca wrote:
> Juliette wrote:
>> Contrary to the (non-)problem highlighted by another poster, having
>> several expressions here that could be true, is not a problem.
>
> I apologize for not checking before posting (I was thinking C, where it
> is illegal to have different cases with the same value).
>
> Thank you for catching my error and calling attention to it.

No probs, happens to the best of us.

>
>> Switch will execute the first case it comes across which is valid. If
>> that case is closed by 'break;', it will then terminate the switch, if
>> the case is closed by 'continue;' it will continue to evaluate the other
>> options too.
>
> `continue` will behave exactly like break.

Oops, I posted this bit too quickly - not having anything, i.e. not
break, nor continue, will let the switch 'continue' / fall through and
continue with the next case.

>
> 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.

I have never tested a switch with several 'default:' cases - as far as I
know, that /should/ be illegal in php too, but it being the flexible
language it is, it may only throw a warning or not even that.

Thanks for pointing out that it will use the last one in that case. I
would have expected it to execute both in the order it came across them,
but then again, thinking it over, the default in php by definition
should be the last case, so it only executing the last one shouldn't
surprise me.

No matter what, having several 'default:' cases is *always* highly
inadvisable.


>
>> In other words choosing the order of your cases is very important if you
>> use this syntax when several cases can be true.
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация