3v4l.org

run code in 300+ PHP versions simultaneously
<?hh class TestingMethods { // can't do public int get() public function get() { return (int) 1; } public function get($withParams) { return (int) 2; } public function getSomething(String $something) { return "something $something"; } public function getSomething() { return "something do with with no @params"; } } $t = new TestingMethods(); $one = $t->get(); $two = $t->get($withParams); $something = $t->getSomething("something..."); $something2 = $t->getSomething(); var_dump($one); var_dump($two); var_dump($something); var_dump($something2);
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.3 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<?hh class TestingMethods { // can't do public int get() public function get() { return (int) 1; } public function get($withParams) { return (int) 2; } public function getSomething(String $something) { return "something $something"; } public function getSomething() { return "something do with with no @params"; } } $t = new TestingMethods(); $one = $t->get(); $two = $t->get($withParams); $something = $t->getSomething("something..."); $something2 = $t->getSomething(); var_dump($one); var_dump($two); var_dump($something); var_dump($something2);
Output for 8.0.13
Parse error: syntax error, unexpected token "class" in /in/qWDiK on line 3
Process exited with code 255.
Output for 5.4.0 - 5.4.32, 7.3.32 - 7.3.33, 7.4.33
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/qWDiK on line 3
Process exited with code 255.

preferences:
140.19 ms | 402 KiB | 172 Q