3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { const FOO = 'foo'; } class Bar extends Foo { const BAR = 'bar'; } $barClassReflection = new ReflectionClass(Bar::class); $constants = $barClassReflection->getReflectionConstants(); var_dump($constants); foreach ($constants as $constant) { var_dump($constant->getName()); var_dump($constant->class); var_dump($constant->getDeclaringClass()->getName()); var_dump($constant->class === $constant->getDeclaringClass()->getName()); }
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [0]=> object(ReflectionClassConstant)#2 (2) { ["name"]=> string(3) "BAR" ["class"]=> string(3) "Bar" } [1]=> object(ReflectionClassConstant)#3 (2) { ["name"]=> string(3) "FOO" ["class"]=> string(3) "Foo" } } string(3) "BAR" string(3) "Bar" string(3) "Bar" bool(true) string(3) "FOO" string(3) "Foo" string(3) "Foo" bool(true)

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:
50.6 ms | 402 KiB | 8 Q