3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface testi { public function getName() : string; } class A { public $name; public __construct(testi $testi) { $this->name = $testi->getName(); } } $A = new A(new class implements testi { public function getName() : string { return "HOHOI"; } } ); var_dump($A->name);
Output for 7.0.0
Parse error: syntax error, unexpected '__construct' (T_STRING), expecting variable (T_VARIABLE) in /in/YQl01 on line 10
Process exited with code 255.
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/YQl01 on line 4
Process exited with code 255.

preferences:
159.92 ms | 1395 KiB | 24 Q