3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php namespace foo{ echo "1-Inside namespace foo \n"; use My\Full\Classname as Another; use ArrayObject; // importing a global class echo "2-After using ArrayObject line: ".__LINE__."\n"; class Another { public function cname() { echo "line".__LINE__."Method".__METHOD__."\n"; } static function method(){echo "line".__LINE__."Method: ".__METHOD__."\n";} } //This line below is Not working. $obj1 = new namespace\Another; // instantiates object of foo\Another echo "3-After namespace\Another object line: ".__LINE__."\n"; //This line below is Not working. echo "4-".$obj1->method()."\n"; //This line below is Not working. $obj2 = new Another; // instantiates object of class My\Full\Classname echo "5-After Another object line: ".__LINE__."\n"; //This line below is Not working. echo "6-".$obj2->method()."\n"; echo "7-After Another object line: ".__LINE__."\n"; //This line below is Not working. $a = new ArrayObject(array(1)); // instantiates object of ArrayObject echo "8-After ArrayObject line: ".__LINE__."\n"; } namespace My\Full{ class Classname{ public function cname() { echo "line".__LINE__."Method".__METHOD__."\n"; } static function method(){echo "line".__LINE__."Method: ".__METHOD__."\n";} } }
Output for 5.3.0 - 5.6.28, 7.0.20 - 7.2.0
Fatal error: Cannot declare class foo\Another because the name is already in use in /in/HELPM on line 7
Process exited with code 255.
Output for 7.0.0 - 7.0.6
1-Inside namespace foo 2-After using ArrayObject line: 6 3-After namespace\Another object line: 15 line11Method: foo\Another::method 4- 5-After Another object line: 20 line35Method: My\Full\Classname::method 6- 7-After Another object line: 23 8-After ArrayObject line: 26
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/HELPM 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/HELPM on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/HELPM on line 2
Process exited with code 255.