3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace Foo\Bar { class a {} class b {} function a() { var_dump(__FUNCTION__); } function b() { var_dump(__FUNCTION__); } const a = 1; const b = 2; } namespace PrePhp7 { use Foo\Bar\a; use Foo\Bar\b; use function Foo\Bar\a; use function Foo\Bar\b; use const Foo\Bar\a; use const Foo\Bar\b; echo "\n" . __NAMESPACE__ . "\n"; var_dump(new a()); var_dump(new b()); a(); b(); var_dump(a); var_dump(b); } namespace Php7 { use Foo\Bar\{a, b}; use function Foo\Bar\{a, b}; use const Foo\Bar\{a, b}; echo "\n" . __NAMESPACE__ . "\n"; var_dump(new a()); var_dump(new b()); a(); b(); var_dump(a); var_dump(b); } namespace Php7Mixed { use Foo\Bar\{a, b, function a, function b, const a, const b}; echo "\n" . __NAMESPACE__ . "\n"; var_dump(new a()); var_dump(new b()); a(); b(); var_dump(a); var_dump(b); }
Output for hhvm-3.15.4, 7.0.0 - 7.3.0rc3
PrePhp7 object(Foo\Bar\a)#1 (0) { } object(Foo\Bar\b)#1 (0) { } string(9) "Foo\Bar\a" string(9) "Foo\Bar\b" int(1) int(2) Php7 object(Foo\Bar\a)#1 (0) { } object(Foo\Bar\b)#1 (0) { } string(9) "Foo\Bar\a" string(9) "Foo\Bar\b" int(1) int(2) Php7Mixed object(Foo\Bar\a)#1 (0) { } object(Foo\Bar\b)#1 (0) { } string(9) "Foo\Bar\a" string(9) "Foo\Bar\b" int(1) int(2)
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected '{', expecting identifier (T_STRING) in /in/BFrkc on line 30
Process exited with code 255.