3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $A = new class() { private $name; function __construct(string $name) { $this->name = $name; } public function getName() : string { return $this->name; } }; $B = new $A('Matti'); $C = new $A('Pekka'); var_dump($B === $C);
based on c6nY0
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function class@anonymous::__construct(), 0 passed in /in/Z26WH on line 3 and exactly 1 expected in /in/Z26WH:6 Stack trace: #0 /in/Z26WH(3): class@anonymous->__construct() #1 {main} thrown in /in/Z26WH on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Fatal error: Uncaught TypeError: Argument 1 passed to class@anonymous::__construct() must be of the type string, none given, called in /in/Z26WH on line 3 and defined in /in/Z26WH:6 Stack trace: #0 /in/Z26WH(3): class@anonymous->__construct() #1 {main} thrown in /in/Z26WH on line 6
Process exited with code 255.
Output for 5.4.10 - 5.6.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/Z26WH on line 3
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_CLASS in /in/Z26WH on line 3
Process exited with code 255.