3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { static function f() { $php = ' $c = new class () { const U = 21; function f() { return #[A(self::U)] static function () {}; } }; return $c->f(); '; return eval($php); } } $rf = new \ReflectionFunction(C::f()); $ra = $rf->getAttributes()[0]; print $ra->getArguments()[0];
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.6
21
Output for 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Call to undefined method ReflectionFunction::getAttributes() in /in/g7Vea:21 Stack trace: #0 {main} thrown in /in/g7Vea on line 21
Process exited with code 255.

preferences:
125.33 ms | 401 KiB | 121 Q