Results 1 to 2 of 2
Oct 15, 2001, 01:55 #1
How to globals work ? examples...
I know that globals are much more secure and, well to put it bluntly, better in everyway. Will someone show me some examples of how globals work, on the same page, on multiple pages etc. I just don't understand them....
Thanks, Chris.cgi://www.scriptingx.com - Everything CGI
Oct 16, 2001, 00:30 #2
- Join Date
- Oct 2000
- 0 Post(s)
- 0 Thread(s)
Umm... If you mean global variables then you're wrong. They are not more secure, they are not better, they are simply more conviniant.
Global variables a pain in PHP because they don't scope as you would expect if you've been programing in other languages befor.
Here's a bit of an example:
$local_var = 100;
$var2 = 10;
echo "This is a passed in variable: $var";
echo "This is a local var: $var2";
echo "This is a golbal var: $global_var";
echo "This is a local var I don't have access to: $local_var";
$global_var = 200;
So, the above example will print
This is a passed in variable: 300
This is a local var: 10
This is a global var: 200
This is a var I don't have access to:
I hope that made sence...but I get the suspicion you wern't really talking about golbal vars...