3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute] class y { function foo() { return __METHOD__; } } #[X, Y] function f() { } $ref = new \ReflectionFunction('\f'); try { if ($ref->getAttributes()[0]->getName() === 'X') { print 'Look mom! No hands' . PHP_EOL; } if ($ref->getAttributes()[1]->getName() === 'Y') { print $ref->getAttributes()[1]->newInstance()->foo(); } } catch (\Error $e) { # other errors var_dump($e->getMessage()); } ?>

preferences:
17.64 ms | 852 KiB | 5 Q