Skip to content

Instantly share code, notes, and snippets.

@DNA

DNA/php_as_js.php

Created Dec 11, 2013
Embed
What would you like to do?
<?php
class myStdClass {
public function __call($method, $args) {
if (isset($this->$method)) {
return call_user_func_array($this->$method, $args);
}
}
}
$x = new myStdClass;
$x->a = function () {
$D = new myStdClass;
$D->c = 5;
$D->b = function () use ($D) {
return $D->c;
};
return $D;
};
echo $x->a()->b();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment