global vars in a function

From: Date: Sat, 30 Mar 2002 04:53:54 +0000
Subject: global vars in a function
Groups: php.general 
Request: Send a blank email to php-general+get-90747@lists.php.net to get a copy of this message
Hi, Am I missing something? I'm trying to use vars set in my config.php file in a function, and can't seem to do it without using $GLOBALS["varname"], which is a bit of a pain in the.... ---config.php--- $var1 = 1; --- ---something.php--- function foo { if($var1) { echo "foo"; // doesn't work } } function foo2 { if($GLOBALS["var1"]) { echo "foo"; // does work } } --- Is there a way to make global vars available in each function, or is this just the way things go? Justin French --------------------- http://indent.com.au http://soundpimps.com ---------------------

« previous php.general (#90747) next »