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 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
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.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
62.18 ms | 407 KiB | 5 Q