Bugs & Features

3v4l.org - online PHP & HHVM shell, execute code in 100+ different versions!

<?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 hhvm-3.5.0
Fatal error: Stack overflow in /in/K0aIc on line -1
Process exited with code 255.
Output for hhvm-3.3.1 - 3.4.1
Fatal error: Stack overflow in /in/K0aIc on line 15
Process exited with code 255.
Output for 5.4.36 - 5.4.37, 5.5.20 - 5.5.21, 5.6.4 - 5.6.5, php7@20141201 - 20150201

Process exited with code 135.
Output for 5.3.0 - 5.4.35, 5.5.0 - 5.5.19, 5.6.0 - 5.6.3, php7@20140507 - 20141101

Process exited with code 139.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/K0aIc on line 67
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/K0aIc on line 67
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/K0aIc on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/K0aIc on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/K0aIc on line 4
Process exited with code 255.