Created
May 20, 2013 04:13
-
-
Save kaja47/5610375 to your computer and use it in GitHub Desktop.
PHP or: how I learned to stop worrying and define functions with reserved names
This file contains hidden or 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
| <?php | |
| class Magic { | |
| function _list() { return "list"; } | |
| function _function() { return "function"; } | |
| function _and() { return "and"; } | |
| function __call($name, $args) { return $this->{"_$name"}(); } | |
| } | |
| $m = new Magic; | |
| var_dump($m->list()); | |
| var_dump($m->function()); | |
| var_dump($m->and()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment