Re: Global variable
| From: | Daniel Convissor | Date: | Thu, 20 Jul 2000 22:20:04 +0000 |
| Subject: | Re: Global variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7494@lists.php.net to get a copy of this message | ||
Hi:
> how i can define global variable for all php scripts in my Web project ?
You've got a few options.
* The define() function creats constants.
* You can stick a value upon the $GLOBALS[VariableName]. Then, you'll
need to use the "global $GLOBALS;" in each function you need it in.
* You can just create a variable $VariableName and then use the
"global $VariableName" in each function you need it in.
* You can create a class and declare the $ClassName->VariableName
outside the class or $this->VariableName inside the class OR
"var $VariableName = ..." inside the class too.
Choice depends on what you're doing.
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
More than just answers. Solutions. (SM)
http://www.analysisandsolutions.com/
4015 7 Av #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409