Re: globals

From: Date: Sat, 16 Dec 2000 23:32:52 +0000
Subject: Re: globals
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-5293@lists.php.net to get a copy of this message
Global variables are only available in other scripts if the other scripts are included into the script where the variable exists. To help understand this concept, remember that every file you include is inserted inline into the main script file before it is executed. You end up with one long script before the code is actually executed; so if you have a global variable in one, it will be available in all the others too. Hope this helps. Toby Butzon [ criticism spurs improvement ] ----- Original Message ----- From: "Bart A. Verbeek" <b.a.verbeek@wanadoo.nl> To: "PHP-DB mailinglist" <php-db@lists.php.net> Sent: Saturday, December 16, 2000 6:35 PM Subject: RE: [PHP-DB] globals : Does that globalisation meen that it is also available in other scripts?? : : -----Oorspronkelijk bericht----- : Van: Dave VanAuken [mailto:dave@hawk-systems.com] : Verzonden: zaterdag 16 december 2000 17:08 : Aan: php-db@lists.php.net : Onderwerp: RE: [PHP-DB] globals : : : global just makes it available within the function, you then call the : variable as normal : : using your code: : : $j = 0; : function doThis($tempVariable) { : global $myArray; : if ($myArray[$j] == $tempVariable) { : echo "whatever"; : } : $j++; : } : : : -----Original Message----- : From: John Starkey [mailto:jstarkey@advancecreations.com] : Sent: Saturday, December 16, 2000 10:56 AM : To: Dave VanAuken : Cc: php-db@lists.php.net : Subject: RE: [PHP-DB] globals : : : > $myArray; : > $myVariable; : > doThis($myVariable); : > : > : > function doThis($tempVariable) { : > global $myArray; : > # do whatever : > } : : Then how wuld I declare the global as the condition of an if? : : $j = 0; : function doThis($tempVariable) { : if (global $myArray[$j] == $tempVariable) { : echo "whatever"; : } : $j++; : } : : : Thanks, : : John : : > -----Original Message----- : > From: John Starkey [mailto:jstarkey@advancecreations.com] : > Sent: Saturday, December 16, 2000 3:19 AM : > To: php-db@lists.php.net : > Subject: [PHP-DB] globals : > : > : > Hello all. : > : > What are the rules for globals? I've seen them in tutorials but have had a : > hard time implementing them. I need to create an array outside of a : > function, pass a variable to that function, and then call the array for : > comparison to that variable. I can't pass the array to the function. : > : > : > Thanks, : > : > John : > : > : > : : : : -- : PHP Database Mailing List (http://www.php.net/) : To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net : For additional commands, e-mail: php-db-help@lists.php.net : To contact the list administrators, e-mail: php-list-admin@lists.php.net : : : : : -- : PHP Database Mailing List (http://www.php.net/) : To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net : For additional commands, e-mail: php-db-help@lists.php.net : To contact the list administrators, e-mail: php-list-admin@lists.php.net : :

« previous php.db (#5293) next »