Skip to content

Instantly share code, notes, and snippets.

@PieterScheffers
Created December 27, 2017 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PieterScheffers/b31ca8a0aeae3dda7f98ec5084483397 to your computer and use it in GitHub Desktop.
Save PieterScheffers/b31ca8a0aeae3dda7f98ec5084483397 to your computer and use it in GitHub Desktop.
PHP Dynamic class
<?php
class stdObject {
public function __call($method, $arguments) {
return call_user_func_array(Closure::bind($this->$method, $this, get_called_class()), $arguments);
}
}
$obj = new stdObject();
$obj->test = function() {
echo "<pre>" . print_r($this, true) . "</pre>";
};
$obj->test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment