When you're working with MVC design pattern, and you want to make variables accessible in the global scope, some say it is better to do it with static methods/properties than with $GLOBALS array.Why is that?
Thanks.
Readie
4:11 pm on Sep 10, 2011 (gmt 0)
Well, static variables are shared between all instances of that class, so in a sense they are global. You can get/set them at any time outside of the class with a className::$varName too (as long as they are public). I suppose the best reason I can think of to use a static var over GLOBALS is it reduces the chances of clashing variable names when different scripts are ran on the same page load.