3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_PROPERTY)] enum Types { case Int32; case Int64; case Float32; } define('Float32', Types::Float32); define('Int64', Types::Int64); define('Int32', Types::Int32); class Test { #[Int32] #[Blah] public int $value; } $t = new Test(); $r = new ReflectionClass($t); $attr = $r->getProperty('value')->getAttributes(); foreach($attr as &$a) { if (class_exists($a->getName())) { $a = $a->newInstance(); } else if(defined($a->getName())) { $a = constant($a->getName()); } } var_dump($attr);
Output for git.master_jit, git.master
array(2) { [0]=> enum(Types::Int32) [1]=> &object(ReflectionAttribute)#8 (1) { ["name"]=> string(4) "Blah" } }

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:
30.49 ms | 405 KiB | 5 Q