3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace Foo\Bar { class a { } class b { } function a() { return 'function a'; } function b() { return 'function b'; } const a = 'const a'; const b = 'const b'; } namespace { 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; var_dump(new a()); var_dump(new b()); var_dump(a()); var_dump(b()); var_dump(a); var_dump(b); } namespace { use Foo\Bar\a, Foo\Bar\b; use function Foo\Bar\a, Foo\Bar\b; use const Foo\Bar\a, Foo\Bar\b; var_dump(new a()); var_dump(new b()); var_dump(a()); var_dump(b()); var_dump(a); var_dump(b); } namespace { use Foo\Bar\{a, b}; use function Foo\Bar\{a, b}; use const Foo\Bar\{a, b}; var_dump(new a()); var_dump(new b()); var_dump(a()); var_dump(b()); var_dump(a); var_dump(b); } namespace { use Foo\Bar\{a, b, function a, function b, const a, const b,}; var_dump(new a()); var_dump(new b()); var_dump(a()); var_dump(b()); var_dump(a); var_dump(b); }
Output for 7.2.0 - 7.2.9
object(Foo\Bar\a)#1 (0) { } object(Foo\Bar\b)#1 (0) { } string(10) "function a" string(10) "function b" string(7) "const a" string(7) "const b" object(Foo\Bar\a)#1 (0) { } object(Foo\Bar\b)#1 (0) { } string(10) "function a" string(10) "function b" string(7) "const a" string(7) "const b" object(Foo\Bar\a)#1 (0) { } object(Foo\Bar\b)#1 (0) { } string(10) "function a" string(10) "function b" string(7) "const a" string(7) "const b" object(Foo\Bar\a)#1 (0) { } object(Foo\Bar\b)#1 (0) { } string(10) "function a" string(10) "function b" string(7) "const a" string(7) "const b"
Output for 7.0.0 - 7.1.21
Parse error: syntax error, unexpected '}', expecting identifier (T_STRING) or function (T_FUNCTION) or const (T_CONST) in /in/kkkUF on line 55
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Syntax only allowed in Hack files (<?hh) or with -v Eval.EnableHipHopSyntax=true in /in/kkkUF:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.15.4 - 3.21.3
Fatal error: Uncaught Error: Syntax only allowed in Hack files (<?hh) or with -v Eval.EnableHipHopSyntax=true in /in/kkkUF:55 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.30
Parse error: syntax error, unexpected '{', expecting identifier (T_STRING) in /in/kkkUF on line 42
Process exited with code 255.