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'); var_dump($user); $user->setEmail('foo2@bar.baz'); var_dump($user);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property User::$email is deprecated in /in/PZn2B on line 15 object(User)#1 (1) { ["email"]=> string(1) "f" } object(User)#1 (1) { ["email"]=> string(12) "foo2@bar.baz" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
47.71 ms | 401 KiB | 8 Q