Last active
December 23, 2015 03:29
-
-
Save vdubyna/6574182 to your computer and use it in GitHub Desktop.
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 | |
| /** | |
| * PHP also could behave as prototype object | |
| */ | |
| class Object { | |
| public function __call($name, $args) | |
| { | |
| return call_user_func_array( | |
| $this->$name, | |
| $args | |
| ); | |
| } | |
| } | |
| $app = new Object(); | |
| $app->action = function ($hello) { | |
| echo "Hello: {$hello}"; | |
| }; | |
| $app->action('World'); // Hello: World | |
| $app->action = function ($wtf) { | |
| echo "WTF: {$wtf}"; | |
| }; | |
| $app->action('World'); // WTF: World |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment