3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_FUNCTION)] class Test {} class Foo { #[Test] public int $test; } echo "Creating foo: "; $f = new Foo(); echo "done\n"; echo "Performing reflection: "; $foo = new ReflectionClass($f); $test = $foo->getProperty('test'); $attributes = $test->getAttributes(); echo "done\n"; echo "instantiating attribute ["; foreach ($attributes as $attribute) { echo $attribute->getName() . ']: '; $attribute->newInstance(); } echo "\n";
Output for git.master_jit, git.master
Creating foo: done Performing reflection: done instantiating attribute [Test]: Fatal error: Uncaught Error: Attribute "Test" cannot target property (allowed targets: function) in /in/UqQKi:24 Stack trace: #0 /in/UqQKi(24): ReflectionAttribute->newInstance() #1 {main} thrown in /in/UqQKi on line 24
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:
33.53 ms | 405 KiB | 5 Q