this time online business to explain about global variable, what is global variable let's
we see. a global variable can be accessed in any part of the program. However, in order to be modified, a global variable must be explicitly declared to be global in the function in which it is to be modified.
This is accomplished, conveniently enough, by placing the keyword GLOBAL in front of the variable that should be recognized as global.
Placing this keyword in front of an already existing variable tells PHP to use the variable having that name. Consider an example:
$somevar = 15;
function addit() {
GLOBAL $somevar;
$somevar++;
print "Somevar is $somevar";
}
addit();
The displayed value of $somevar would be 16. However, if you were to omit this
line:
GLOBAL $somevar;
An alternative method for declaring a variable to be global is to use PHP's $GLOBALS
array. Reconsidering the above example, I use this array to declare the variable
$somevar to be global:
$somevar = 15;
function addit() {
$GLOBALS["somevar"];
$somevar++;
}
addit();
print "Somevar is $somevar";
bookmark here
My Blog List
Search Engine Optimization and SEO Tools
LinkAlizer makes it easy and fast for you to to find link exchange partners and increase traffic.
Subscribe to Business by Email
Duane Gartman - Seo Friendly Web Directory
Web Directory
SEO Master Iftekhar khan General Web Directory
Free Link Exchange Directory Submit Links
Submit Links To WahmD.Com Free Link Directory Submission Exchange Free web directory
Submit Links To WahmD.Com Free Link Directory Submission Exchange Free web directory
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment