3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { public function __call($name, $value) { $type = substr($name, 0, 3); $variable = lcfirst(substr($name, 3)); if($type == 'get'){ return $this->$variable; } if($type == 'set'){ $this->$variable = $value[0]; return $this; } return call_user_func_array(array($this, $name), $value); } public function setEmail($email) { $trace=debug_backtrace(); $caller=array_shift($trace); echo "Called by {$caller['function']}"; if (isset($caller['class'])) { echo " in {$caller['class']}"; } $this->email = $email; return $this; } } $user = new User(); $user->__call('setEmail', 'foo@bar.baz'); $user->setEmail('foo2@bar.baz');

preferences:
40.15 ms | 402 KiB | 5 Q