3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Name\Space { function bar() { echo "bar over here!"; } } namespace Some\Other { class Foo { use function Name\Space\bar; const bar = 'yo'; function baz() { $this->bar = function() {echo 'im a callable bar';}; } } } $foo = new Foo(); $foo->baz(); $foo->bar();
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) or namespace (T_NAMESPACE) or \\ (T_NS_SEPARATOR) in /in/F9RPM on line 12
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/F9RPM on line 12
Process exited with code 255.

preferences:
174.55 ms | 1395 KiB | 67 Q