On Tuesday 12 March 2002 11:11, Analysis & Solutions wrote:
> On Mon, Mar 11, 2002 at 08:39:16PM -0500, webapprentice wrote:
> > From: Jason Wong <[EMAIL PROTECTED]>
> >
> > On Monday 11 March 2002 11:10, Chris Cocuzzo wrote:
> > > $foo = "Entry for " . $HTTP_POST_VARS["name"];
> >
> > $foo = "Entry for for $HTTP_POST_VARS[name]";
>
> But that's not good programming. Associative arrays should have the key
> quoted in order to avoid confusion with contants. See
> http://www.php.net/manual/en/language.types.array.php#language.types.array.
>donts
Inside of double-quoted strings there is no need to single-quote the array
key (in fact it can't be done, gives syntax error). The section of the manual
you quoted states this :)
[snip]
> Now, I wonder why you're even assigning this information to yet another
> varialbe. Why not just use the information straight up?:
> echo "Entry for for $name";
>
> Of course, there are legitimate reasons for your approach, but often new
> programmers needlessly assign stuff to varialbes. Just making sure.
For security reasons. To make sure the variable did come from POSTing a form
and not from the URL.
> Finally, if you really want to use $HTTP_POST_VARS[] AND your'e
> running PHP 4.1*, consider using the superglobal $_POST[] instead.
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
Nobody knows what goes between his cold toes and his warm ears.
-- Roy Harper
*/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php