Hi
What's the best way to create a variable that is created OUTSIDE of Classes, but accessible from inside all Classes... I don't want to use Session Variables unless absolutely necessary.
Thnx
GLOBAL / PUBLIC variables
Moderator: General Moderators
-
msurabbott
- Forum Commoner
- Posts: 33
- Joined: Thu Jan 01, 2009 10:18 pm
- Location: Chicago, IL, USA
Re: GLOBAL / PUBLIC variables
Global and Session variables are different really only in the manor they are accessed and created. If you want to avoid using $_SESSION you can use global.
Create the variable like so:
Then whenever you want to access it just do:
Create the variable like so:
Code: Select all
global $var;
$var = "15"Code: Select all
global $var;
echo $var;