Global vars

From: Date: Sun, 02 Jun 2002 06:30:03 +0000
Subject: Global vars
Groups: php.general 
Request: Send a blank email to php-general+get-100292@lists.php.net to get a copy of this message
I have a question about global vars. Why is it that I have to declare a var global if I'm using it across included files. For example the only why I can get this var to work is by making it global. main.php <?php include loader.inc; include builder.inc; include render.inc; ?> loader.inc <?php global $obj; $obj = new Whiz_bang(); ?> builder.inc <?php global $obj; $obj->build_whizzer(); ?> render.inc <?php render->html(); ?> considering that if you took the could and just inserted the code form the included files into the main you would not need to make the var global why is that I need to when I cross files. I don't think I have read a good reasoning for this anywhere. My goal is simple to use as few global vars as possible which is why I ask. _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com

« previous php.general (#100292) next »