Re: tutorial on global variables

From: Date: Sat, 27 Apr 2002 20:39:05 +0000
Subject: Re: tutorial on global variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-94943@lists.php.net to get a copy of this message
jlhughes@yahoo.com (John Hughes) wrote: > Can someone point me toward a tutorial on the proper use of global > references under PHP4. > > I have been declaring > > function something() > { > global $foo, $bar; > > /* some actions */ > > } > > in functions and I understand that this is not the way I'm supposed > to be doing this. Or there is a new way that is preferred. you can do it that way, but if you want to avoid calling global all the time you might consider this approach: $GLOBALS["foo"] = 123; function something() { echo $GLOBALS["foo"]; } -- Henrik Hansen

« previous php.general (#94943) next »