Janwillem Borleffs wrote:
Ewoud Dronkert wrote: On Sun, 22 May 2005 22:51:03 +0200, Janwillem Borleffs wrote: switch(${"g{$i}R"})...
Yeah, but *really*!
Really what? What doesn't look good to you does not mean that it
isn't possible.
There are *lots* of things that are *possible* in PHP that are very bad
from a programmatic point of view; that doesn't mean that they should
be used!!
It's now up to the OP to chose between your suggestion and the
original approach he wanted to implement.
The problem is, I'm guessing you're a pretty good programmer, and you
know how to do things sensibly, as well as how to do clever tricks like
that.
Judging by the OP's original code snippet, he probably has the attidue
that "arrays are more trouble than they're worth, and take more
typing", or may not even know what arrays are, and will use your
suggestion because it solves his immediate problem without having to
change the rest of his code.
And then he'll go off and write all his PHP scripts using horrible
convoluted expressions like that, rather than taking the time to learn
how to do things properly. Which will lead to his needing to use even
more complicated trickery to fix things later down the line (and
probably use eval() as well!)
IMO, it's the "responsibility" of people who know what they're doing to
encourage good programming practice, or at the very least explain that
things like the above are to be avoided! But that's just my opinion.
--
Oli