3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Intercept { protected $class = null; protected $callback = null; public function __construct($class, $callback = null) { $this->class = new $class(); $this->callback = $callback; } protected function run_callback() { $this->$callback(); } public function __get($name) { $this->run_callback(); return $this->class->$name; } public function __set($name, $value) { $this->run_callback(); return $this->class->$name = $value; } public function __isset($name) { $this->run_callback(); return isset($this->class->$name); } public function __unset($name) { $this->run_callback(); unset($this->class->$name); } public function __call($method, $args) { $this->run_callback(); return call_user_func_array(array($this->class, $method), $args); } public function __toString() { $this->run_callback(); return $this->class; } public function __invoke() { $this->run_callback(); return $this->class(); } } class test { public function hello() { return 'world'; } } $closure = function() { echo 123; }; $test=new Intercept('test', $closure); echo $test->hello();
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $callback in /in/VvEQs on line 15 Fatal error: Uncaught Error: Method name must be a string in /in/VvEQs:15 Stack trace: #0 /in/VvEQs(44): Intercept->run_callback() #1 /in/VvEQs(72): Intercept->__call('hello', Array) #2 {main} thrown in /in/VvEQs on line 15
Process exited with code 255.

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:
44.12 ms | 401 KiB | 8 Q