3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute] class A {} class B {} #[A] function a(): void {} #[B] function b(): void {} $a = new ReflectionFunction('a'); $b = new ReflectionFunction('b'); foreach([$a, $b] as $reflection) { $attributes = $reflection->getAttributes(); foreach ($attributes as $attribute) { var_dump($attribute->getName()); var_dump($attribute->getArguments()); var_dump($attribute->newInstance()); } }
Output for git.master, git.master_jit, rfc.property-hooks
string(1) "A" array(0) { } object(A)#4 (0) { } string(1) "B" array(0) { } Fatal error: Uncaught Error: Attempting to use non-attribute class "B" as attribute in /in/QGQRF:23 Stack trace: #0 /in/QGQRF(23): ReflectionAttribute->newInstance() #1 {main} thrown in /in/QGQRF on line 23
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
25.67 ms | 405 KiB | 5 Q