3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace namespace_breaks_mario_solution_but_not_hans_solution; class C { public const WUT=5; } $v = "WUT"; var_dump(constant(C::class . "::$v")); // << hans solution var_dump(constant("C::$v")); // << mario solution, crash in namespace
Output for 8.1.14 - 8.1.33, 8.2.1 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
int(5) Fatal error: Uncaught Error: Class "C" not found in /in/SUYbi:8 Stack trace: #0 /in/SUYbi(8): constant('C::WUT') #1 {main} thrown in /in/SUYbi on line 8
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.0 - 8.1.13, 8.2.0
int(5) Fatal error: Class "C" not found in /in/SUYbi on line 8
Process exited with code 255.

preferences:
89.71 ms | 408 KiB | 5 Q