Re: PHP globals aren't really globals

From: Date: Wed, 14 Feb 2001 15:20:04 +0000
Subject: Re: PHP globals aren't really globals
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-39640@lists.php.net to get a copy of this message
> Rasmus wrote: > >I swore I would not have the same problem in PHP and thus the requirement > >for people to be explicit about using global variables inside functions. > >Hopefully it also forces a little bit of structure and organization on > >people. > > Hear, hear and thank you Rasmus. It seems to me that the several other ways > folks have listed to solve this one example indicates that we don't really > need the temporary convenience of wide open globals (temporary as in it > doesn't end up very convenient when they create problems). I was always tought very simply, don't use globals :) However, that isn't always an option. I have no problems with the way PHP does things. I think its a good idea for the shelter. What I find interesting is that it seems when you are first learning a language, you use more globals, than when you are more experienced with it. When I first started programmig in C, 99% of my variables were global. Look at any of my C/C++ code nowadays, over 10 years later, and you will be hard pressed to find a global. PHP is still new to me, so i'm still trying to use alot of globals. Because of the way PHP handles it, i'm jumping through a few hoops. That is annoying, but I don't consider it a problem, because as I get better, I know I will go back through and rewrite things to not use globals. I guess my confusion is this: I am passing all my variables around between scripts by sending them through the URLs (index.php?mode=index). I guess what "annoys" me, is I would expect those to be available from inside the functions, but they aren't. - John Vanderbeck - Admin, GameDesign > > Visit the Gates Motel webgame: > http://www.gameslate.com/gatesmotel/ > > > -- > 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 (#39640) next »