3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Point { public function __construct( public float $x, public float $y = 0.0, public float $z = 0.0, ) {} } foreach ((new ReflectionClass(Point::class))->getProperties() as $property) { var_dump($property->name); }
Output for 8.0.0, 8.1.23 - 8.1.34, 8.2.10 - 8.2.32, 8.3.0 - 8.3.32, 8.4.1 - 8.4.23, 8.5.0 - 8.5.8
string(1) "x" string(1) "y" string(1) "z"
Output for 7.3.0 - 7.3.25, 7.4.0 - 7.4.13
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting variable (T_VARIABLE) in /in/JsbXT on line 5
Process exited with code 255.

preferences:
76.9 ms | 1067 KiB | 4 Q