3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Generic\Space { function bar() { echo "bar over here!"; } } namespace Some\Other { class Foo { use \My\TraitSpace\NiceTrait; function baz() { $method = new ReflectionMethod('Some\Other\Foo', 'bar'); $method->setAccessible(false) } function bar() { echo 'declared bar'; } } } namespace My\TraitSpace { use \Generic\Space; trait NiceTrait { function bar() { echo "within the trait!"; } } } namespace { $foo = new Some\Other\Foo(); $foo->baz(); $foo->bar(); }
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected '}' in /in/XZ5CG on line 19
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_USE, expecting T_FUNCTION in /in/XZ5CG on line 14
Process exited with code 255.

preferences:
183.23 ms | 1386 KiB | 67 Q