3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function __construct( public readonly string $foo, public readonly string $bar, ) {} } $list = [ new A('Hello', 'World'), new A('Foo', 'Bar'), new A('Fizz', 'Buzz'), ]; var_dump(array_column($list, 'foo'));
Output for 8.1.20 - 8.1.34, 8.2.7 - 8.2.30, 8.3.5 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array(3) { [0]=> string(5) "Hello" [1]=> string(3) "Foo" [2]=> string(4) "Fizz" }
Output for 8.0.29
Parse error: syntax error, unexpected identifier "string", expecting variable in /in/8Xrts on line 5
Process exited with code 255.
Output for 7.4.33
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting variable (T_VARIABLE) in /in/8Xrts on line 5
Process exited with code 255.

preferences:
65.71 ms | 763 KiB | 4 Q