Created
July 4, 2019 13:04
-
-
Save ad3n/4c5f2a94fad78feb39902f4e9ab66e58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TArrayAccess implements \ArrayAccess | |
{ | |
private $arr; | |
public function offsetExists($offset) | |
{ | |
return isset($this->arr[$offset]); | |
} | |
public function offsetGet($offset) | |
{ | |
return $this->arr[$offset]; | |
} | |
public function offsetSet($offset, $value) | |
{ | |
$this->arr[$offset] = &$value; | |
} | |
public function offsetUnset($offset) | |
{ | |
unset($this->arr[$offset]); | |
} | |
} | |
$a = new TArrayAccess(); | |
$b = 10; | |
$a['a'] = $b; | |
$b = 20; | |
var_dump($a['a']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment