3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL ^ E_STRICT); trait MyTrait { /** * Comes from trait */ private $foo; } class MyClass { use MyTrait; /** * Comes from class */ private $foo; } $classFoo = new \ReflectionProperty('MyClass', 'foo'); $traitFoo = new \ReflectionProperty('MyTrait', 'foo'); var_export($traitFoo->getDocComment() == $classFoo->getDocComment()); $classFoo = new \ReflectionProperty('MyClass','foo'); $traitFoo = new \ReflectionProperty('MyTrait','foo'); echo $traitFoo->getDeclaringClass()->getName().PHP_EOL; echo $traitFoo->getDocComment().PHP_EOL; echo $classFoo->getDeclaringClass()->getName().PHP_EOL; echo $classFoo->getDocComment().PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
falseMyTrait /** * Comes from trait */ MyClass /** * Comes from class */

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:
44.06 ms | 401 KiB | 8 Q