3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { function f() { $php = ' return #[A(self::U)] static function () {}; '; return eval($php); } } $rf = new \ReflectionFunction(C::f()); $ra = $rf->getAttributes()[0]; $ra->getArguments();
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Non-static method C::f() cannot be called statically in /in/1KrQ8:14 Stack trace: #0 {main} thrown in /in/1KrQ8 on line 14
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Deprecated: Non-static method C::f() should not be called statically in /in/1KrQ8 on line 14 Fatal error: Uncaught Error: Call to undefined method ReflectionFunction::getAttributes() in /in/1KrQ8:15 Stack trace: #0 {main} thrown in /in/1KrQ8 on line 15
Process exited with code 255.

preferences:
137.86 ms | 402 KiB | 122 Q