Re: Global Annoyance

From: Date: Mon, 18 Dec 2000 22:19:12 +0000
Subject: Re: Global Annoyance
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30945@lists.php.net to get a copy of this message
What if a variable could be declared global or autoglobal (if global seems ambiguous/confusing) and automatically be global within all functions (without having to declare "global $myvar" inside every function that wants it). For ex., consider this: <? $var1 = 1; autoglobal $var2 = 2; function showme() { echo $var1, $var2; // outputs "2" } ?> If this has been discussed before, my apologies... but wouldn't this give people that want to use c-style globals (automatically available in functions) a choice? While it might not be the best way to go, I'm not really seeing a downside, and at least dev's would have a choice... Toby Butzon [ criticism spurs improvement ] ----- Original Message ----- From: "Jason Murray" <Jason.Murray@melbourneit.com.au> To: <Bill.Hoffman@walgreens.com>; <php-general@lists.php.net> Sent: Monday, December 18, 2000 4:55 PM Subject: RE: [PHP] Global Annoyance : > I would like to have all of my variables available globally : > unless I specify otherwise. If I wanted to make a second : > mail function I would have to declare all of these : > variables all over again. I have had to declare the same : > variable 5 times in 5 different functions. : > Let me know if anyone knows a better way to do this. : : Just a silly thought here, but did you think of writing the functions : to accept input variables? : : Jason : : -- : Jason Murray : jasonm@melbourneit.com.au : Web Design Team, Melbourne IT : Fetch the comfy chair! : : -- : PHP General Mailing List (http://www.php.net/) : To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net : For additional commands, e-mail: php-general-help@lists.php.net : To contact the list administrators, e-mail: php-list-admin@lists.php.net : :

« previous php.general (#30945) next »