Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. <?php
  2.  
  3. $foo = 1;
  4.  
  5. function meh(){
  6. // <-- $foo can't be accessed
  7. }
  8.  
  9. <?php
  10. $a = 1;
  11. $b = 2;
  12.  
  13. function Sum()
  14. {
  15. global $a, $b;
  16.  
  17. $b = $a + $b;
  18. }
  19. ?>
  20.  
  21. <?php
  22. $a = 1;
  23. $b = 2;
  24.  
  25. function Sum()
  26. {
  27. $GLOBALS['b'] = $GLOBALS['a'] + $GLOBALS['b'];
  28. }
  29. ?>
  30.  
  31. <?php
  32.  
  33. $foo = 1;
  34.  
  35. function meh(){
  36. global $foo;
  37. // <-- $foo now can be accessed
  38. }
  39.  
  40. ?>
  41.  
  42. function meh(){
  43. global $foo;
  44. // $foo now exists in this scope
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement