3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace Foo { use Bar as Baz; } namespace Foo { use Baz as Bar; class Bar { public $y = 2; } } namespace Foo { use Bar as Baz; class Baz { public $x = 1; } } namespace { $x = new Foo\Bar(); $y = new Foo\Baz(); echo $x->y; echo $y->x; }
Output for 5.6.30, 7.0.7 - 7.2.9
Fatal error: Cannot declare class Foo\Bar because the name is already in use in /in/Y0uUc on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.6
21
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Cannot declare class Foo\Bar because the name is already in use: (Line: 8, Char: 32) in /in/Y0uUc:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.15.4 - 3.21.3
Fatal error: Uncaught Error: Cannot declare class Foo\Bar because the name is already in use: (Line: 8, Char: 32) in /in/Y0uUc:8 Stack trace: #0 {main}
Process exited with code 255.