Re: Globals

From: Date: Sun, 20 Aug 2000 11:43:33 +0000
Subject: Re: Globals
Groups: php.general 
Request: Send a blank email to php-general+get-12641@lists.php.net to get a copy of this message
Addressed to: "David Schultz" <vvortex1@home.com> <php-general@lists.php.net> ** Reply to note from "David Schultz" <vvortex1@home.com> Sun, 20 Aug 2000 02:29:20 -0700 > This is all very strange to me. I get a nagging feeling that it > shouldn't be this way because I almost never used globals in C++, but > on the other hand, I see no other way. > PHP isn't C++, declaring global variables at the top of functions that use them is the 'clean' way to do it in PHP, at least as long as you know the name of the variable when you write the code. If I don't know the name of a variable when I write the code, I usually pass in the name and use the $GLOBALS[] array. function TextField( $FieldName, $Size ) { echo '<INPUT Type=Text Name=$FieldName Value="', $GLOBALS[ $FieldName ], '" SIZE=', $Size, ">\n"; } Rick Widmer Internet Marketing Specialists www.developersdesk.com

« previous php.general (#12641) next »