Reply to Re: [PHP] Seemingly weird regex problem

Your name:

Reply:


Posted by Richard Lynch on 01/20/05 21:49

Tim Boring wrote:
> It's perfectly legit to use expressions. Now perhaps there is something
> wrong with the regex I'm trying to use, but using a regex in and of
> itself is legal.
> http://www.php.net/manual/en/control-structures.switch.php

Ah...

Well, the User Contributed notes provide some examples, and the manual
says you can use expressions, but nothing clarifies, for me, the
interaction betwee n $x and [expression] in:

switch ($x){
case [expression]: /* code */; break;
}

Is $x compared to the return value of [expression]?

I think what you need, then, is TRUE instead of $x.

.... I think I'll go out on a limb and say that in MOST CASES it would be
Bad Style to have both $x and [expression]... I mean, it just gets too
confusing.

And if you expressions also have side-effects (incrementing, for example)
then it would be REALLY UGLY to do, like:

switch ($x){
case ($x++): /* code */ break;
case ($x): /* code */ break;
}

[shudder]

I pity the programmer that has to make sense of something as messy as that.

Maybe I'm just "missing" a really elegant example of how cool this would
be, but it seems rife for confusion to me.

--
Like Music?
http://l-i-e.com/artists.htm

[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

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