Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Outer {
- protected $data;
- public function __construct($data) {
- /* array access will be implemented by the time we get to here */
- $this->data = $data;
- }
- public function getDataProxy() {
- /* create a proxy object implementing array access */
- return new class extends $this implements ArrayAccess {
- public function offsetGet($offset) { return $this->data[$offset]; }
- public function offsetSet($offset, $data) { return ($this->data[$offset] = $data); }
- public function offsetUnset($offset) { unset($this->data[$offset]); }
- public function offsetExists($offset) { return isset($this->data[$offset]); }
- }($this->data);
- }
- }
- $outer = new Outer($_SERVER);
- $proxy = $outer->getDataProxy();
- var_dump($proxy["argv"]);
- var_dump($proxy["argc"]);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement