Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class myGlobals {
- static $myVariable;
- }
- function a() {
- print myGlobals::$myVariable;
- }
- // in global space
- $myVar = "hello";
- // inside a function
- function foo() {
- echo $GLOBALS['myVar'];
- }
- $GLOBALS['_MYVAR'] = 'foo';
- print_r($_MYVAR);
- Class Registry {
- private $vars = array();
- public function __set($index, $value){$this->vars[$index] = $value;}
- public function __get($index){return $this->vars[$index];}
- }
- $registry = new Registry;
- function _REGISTRY(){
- global $registry;
- return $registry;
- }
- _REGISTRY()->sampleArray=array(1,2,'red','white');
- //_REGISTRY()->someOtherClassName = new className;
- //_REGISTRY()->someOtherClassName->dosomething();
- class sampleClass {
- public function sampleMethod(){
- print_r(_REGISTRY()->sampleArray); echo '<br/>';
- _REGISTRY()->sampleVar='value';
- echo _REGISTRY()->sampleVar.'<br/>';
- }
- }
- $whatever = new sampleClass;
- $whatever->sampleMethod();
- class myGlobals {
- public static $myVariable;
- }
- function Test()
- {
- echo myGlobals::$myVariable;
- }
Add Comment
Please, Sign In to add comment