Created
December 27, 2017 15:48
-
-
Save PieterScheffers/b31ca8a0aeae3dda7f98ec5084483397 to your computer and use it in GitHub Desktop.
PHP Dynamic class
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
<?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