Skip to content

Instantly share code, notes, and snippets.

@vdubyna
Last active December 23, 2015 03:29
Show Gist options
  • Select an option

  • Save vdubyna/6574182 to your computer and use it in GitHub Desktop.

Select an option

Save vdubyna/6574182 to your computer and use it in GitHub Desktop.
<?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