3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function __construct (public readonly array $ary = [0,1,2,3]) {} } $obj = new A; var_dump(current($obj->ary)); next($obj->ary); var_dump(current($obj->ary));
Output for 8.4.1 - 8.4.14, 8.5.0
int(0) Fatal error: Uncaught Error: Cannot indirectly modify readonly property A::$ary in /in/edgYU:12 Stack trace: #0 {main} thrown in /in/edgYU on line 12
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.1.30 - 8.1.33, 8.2.22 - 8.2.29, 8.3.5 - 8.3.28
int(0) Fatal error: Uncaught Error: Cannot modify readonly property A::$ary in /in/edgYU:12 Stack trace: #0 {main} thrown in /in/edgYU on line 12
Process exited with code 255.
Output for 8.0.0 - 8.0.9
Parse error: syntax error, unexpected token "array", expecting variable in /in/edgYU on line 5
Process exited with code 255.
Output for 7.3.0 - 7.3.29, 7.4.0 - 7.4.22
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting variable (T_VARIABLE) in /in/edgYU on line 5
Process exited with code 255.

preferences:
49.02 ms | 412 KiB | 5 Q