3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $foo; private __construct($spam){ $this->foo = $spam; } public function getFoo() { return $this->foo; } } $args = 'bacon'; $class = 'Foo'; $reflClass = new \ReflectionClass($class); $instance = call_user_func(\Closure::bind(function () use ($args) { return new static($args); }, $reflClass->newInstanceWithoutConstructor(), $class)); echo $instance->getFoo();
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected '__construct' (T_STRING), expecting variable (T_VARIABLE) in /in/uSAt7 on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/uSAt7 on line 4
Process exited with code 255.

preferences:
192.23 ms | 1395 KiB | 67 Q