3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo implements Stringable { const HOGE = 'hoge'; public function __toString(): string { return 'HOGE'; } } function f(Stringable $name): void { var_dump(Foo::{(string)$name}); var_dump(Foo::{$name}); } f(new Foo);
Output for 8.3.0 - 8.3.27, 8.4.1 - 8.4.14, 8.5.0
string(4) "hoge" Fatal error: Uncaught TypeError: Cannot use value of type object as class constant name in /in/WZTCC:14 Stack trace: #0 /in/WZTCC(17): f(Object(Foo)) #1 {main} thrown in /in/WZTCC on line 14
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.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.
Output for 8.2.0 - 8.2.29
Parse error: syntax error, unexpected token ")", expecting "(" in /in/WZTCC on line 13
Process exited with code 255.

preferences:
61.75 ms | 408 KiB | 5 Q