Advertisement
Guest User

test_globals_arrayaccess

a guest
Jun 15th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.37 KB | None | 0 0
  1. <?php
  2.     class Globals implements ArrayAccess {
  3.         public function offsetGet($key) {
  4.             return 'Yupp!';
  5.         }
  6.         public function offsetSet($key, $value) {}
  7.         public function offsetUnset($key) {}
  8.         public function offsetExists($key) {}
  9.     }
  10.  
  11.     $GLOBALS = new Globals();
  12.  
  13.     function test_globals() {
  14.         echo $GLOBALS['nonexistent value']; // echoes "Yupp!"
  15.     }
  16.  
  17.     test_globals();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement