declaring variables as “global” in php
Tuesday, December 3rd, 2002I was just working on implementing this credit card validation script . I had been working with a similar version that was on devarticles.com and the script they have there did NOT work. (The one I linked DOES work!) In any case, I noticed in the one that didn’t work, the author was declaring a lot of variables as “global” (this wasn’t the reason why the script wasn’t working), but it made me wonder when you needed to declare variables as global and when you didn’t. A little search on Google, and I found this explanation here: (I am quoting them verbatim - on a side note, for those of you who are interested in a php site for newbies, phpbeginner.com looked pretty good!)
(more…)