3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function __construct( public readonly int $a = 5, ) { echo 2; yield; echo 3; } } class B extends A { public function __construct(int $a) { echo 1; parent::__construct($a); echo 4; } } echo (new B(6))->a;
Output for 8.1.24 - 8.1.34, 8.2.11 - 8.2.30, 8.3.5 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
146
Output for 7.3.33
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting variable (T_VARIABLE) in /in/i7lf7 on line 6
Process exited with code 255.

preferences:
55.59 ms | 744 KiB | 4 Q