3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Some\Trait { function bar() { echo "bar over here!"; } } namespace Some\Other { class Foo { use Some\Trait; function baz() { $this->bar = function() {echo 'im a callable bar';}; } } } namespace { $foo = new Some\Other\Foo(); $foo->baz(); $foo->bar(); }
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR), expecting '{' in /in/JYR2c on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING in /in/JYR2c on line 3
Process exited with code 255.

preferences:
184.89 ms | 1395 KiB | 67 Q