fork download
  1. <?php
  2. $globVar = 'Something';
  3.  
  4. class test{
  5. public function run(){
  6. printf("Method 'run' (no global): %s\n", $globVar);
  7. }
  8. }
  9.  
  10. $t = new test();
  11. $t->run();
  12.  
  13.  
  14.  
  15. $globVar1 = 'Something';
  16.  
  17. class test1{
  18. public function run(){
  19. global $globVar1;
  20.  
  21. printf("Method 'run' (global): %s\n", $globVar1);
  22. }
  23. }
  24.  
  25. $t1 = new test1();
  26. $t1->run();
Success #stdin #stdout #stderr 0.02s 52472KB
stdin
Standard input is empty
stdout
Method 'run' (no global): 
Method 'run' (global): Something
stderr
PHP Notice:  Undefined variable: globVar in /home/GIW36g/prog.php on line 6