|
Posted by shimmyshack on 03/24/07 19:06
On 24 Mar, 15:37, Mary Pegg <inva...@invalid.com> wrote:
> Rami Elomaa wrote:
> > Let's try again, shall we.
>
> > for($counter=1;$counter<6;$counter++)
> > if (isset($c['s']['a'.$counter]))
> > echo $c['s']['a'.$counter]."<br>";
>
> what I've got anyway. There's lots of other things coming out of
which is why you shouldnt be doing it this way
> $c['s'], and the existing way is arguably more readable.
that's a daft reason, its completely unmaintainable and unextensible
no more readable to someone familiar with other basic php constructs
what if you start learning about XSS and decide you need to protect
yourself against it, then you will have to find examples such as this
and change them all to
if (isset($c['s']['a5'])) echo htmlentities($c['s']['a1'])."<br>";
..
..
..
if (isset($c['s']['a5'])) echo htmlentities($c['s']['a5'])."<br>";
that's alot of work for sake of sticking with what _you_ find more
readable
and what if you then decide you need your pages to validate to xhtml?
oh dear another trip through all your scripts:
if (isset($c['s']['a5'])) echo htmlentities($c['s']['a1'])."<br />";
..
..
..
if (isset($c['s']['a5'])) echo htmlentities($c['s']['a5'])."<br />";
what if you add more tha a5, or if you change the keys
uh oh!
there are standards in programming, designed to make code more
acceptable to others coming after you
all the chages above and more are so simple with Rani's method. If you
can't take good advice don't ask for it.
Navigation:
[Reply to this message]
|