Reply to Re: switch easy

Your name:

Reply:


Posted by Michael Fesser on 06/25/07 00:30

..oO(Geoff Berrow)

>Message-ID: <467ecee0$0$10863$426a74cc@news.free.fr> from Séverin
>Richard contained the following:
>
>>Thank you for your answer
>>
>>I have many different extention to deal with and i will use switch
>>rather than ternary operator.
>
>I still find little use for switch and prefer to use an array instead.

In a situation like this a switch is the perfect solution:

switch ($foo) {
case 1: doThis(); break;
case 2: doThat(); break;
case 3: doSomething(); break;
case 4: doSomethingElse(); break;
default: doWhatever();
}

The alternative would be a cascade of 4 if-else statements ... Ugly.

Micha

[Back to original 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

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