3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace App; class Bar {}; class Baz {}; class Foo { public function __construct( private Bar $bar, private Baz $baz ) {} } var_dump(new Foo(new Bar, new Baz));
Output for 8.0.0 - 8.0.24, 8.1.0 - 8.1.11
object(App\Foo)#1 (2) { ["bar":"App\Foo":private]=> object(App\Bar)#2 (0) { } ["baz":"App\Foo":private]=> object(App\Baz)#3 (0) { } }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.32
Parse error: syntax error, unexpected 'private' (T_PRIVATE), expecting variable (T_VARIABLE) in /in/tN4HM on line 10
Process exited with code 255.

preferences:
57.49 ms | 410 KiB | 5 Q