3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php final class Container{ private $callables =[]; public function __set(string $name,$value){ if($value instanceof Closure){ $this->callables[$name] = $value; } } public function __call(string $method, array $args){ if(isset($this->callables[$method])){ $callable = $this->callables[$method]; $callable($args); } } } $container = new Container(); $container->demo = function(){ return new Caontainer(); }; var_dump($container->demo());
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Class 'Caontainer' not found in /in/jOiLQ:22 Stack trace: #0 /in/jOiLQ(15): {closure}(Array) #1 /in/jOiLQ(25): Container->__call('demo', Array) #2 {main} thrown in /in/jOiLQ on line 22
Process exited with code 255.
Output for 5.4.10 - 5.6.28
Catchable fatal error: Argument 1 passed to Container::__set() must be an instance of string, string given in /in/jOiLQ on line 6
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/jOiLQ on line 4
Process exited with code 255.