3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php namespace Foo\Bar; include 'file1.php'; const FOO = 2; function foo() {} class foo { static function staticmethod() {} } /* Unqualified name */ foo(); // resolves to function Foo\Bar\foo foo::staticmethod(); // resolves to class Foo\Bar\foo, method staticmethod echo FOO; // resolves to constant Foo\Bar\FOO /* Qualified name */ subnamespace\foo(); // resolves to function Foo\Bar\subnamespace\foo subnamespace\foo::staticmethod(); // resolves to class Foo\Bar\subnamespace\foo, // method staticmethod echo subnamespace\FOO; // resolves to constant Foo\Bar\subnamespace\FOO /* Fully qualified name */ \Foo\Bar\foo(); // resolves to function Foo\Bar\foo \Foo\Bar\foo::staticmethod(); // resolves to class Foo\Bar\foo, method staticmethod echo \Foo\Bar\FOO; // resolves to constant Foo\Bar\FOO ?>
Output for 7.0.0 - 7.1.0
Warning: include(file1.php): failed to open stream: No such file or directory in /in/QY6L9 on line 3 Warning: include(): Failed opening 'file1.php' for inclusion (include_path='.:') in /in/QY6L9 on line 3 2 Fatal error: Uncaught Error: Call to undefined function Foo\Bar\subnamespace\foo() in /in/QY6L9:18 Stack trace: #0 {main} thrown in /in/QY6L9 on line 18
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Warning: File not found: file1.php in /in/QY6L9 on line 3 2 Fatal error: Call to undefined function Foo\Bar\subnamespace\foo() in /in/QY6L9 on line 18
Process exited with code 255.
Output for 5.3.0 - 5.6.28
Warning: include(file1.php): failed to open stream: No such file or directory in /in/QY6L9 on line 3 Warning: include(): Failed opening 'file1.php' for inclusion (include_path='.:') in /in/QY6L9 on line 3 2 Fatal error: Call to undefined function Foo\Bar\subnamespace\foo() in /in/QY6L9 on line 18
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/QY6L9 on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/QY6L9 on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/QY6L9 on line 2
Process exited with code 255.