3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Foo { use function foo; function foo(string $str) : int { return foo($str) + 1; } } namespace { function foo(string $str) : int { return strlen($str) * 5; } } namespace Foo { var_dump(foo("abc")); }
Output for 8.5.0 - 8.5.3
Fatal error: Cannot redeclare function Foo\foo() (previously declared as local import) in /in/G4ZWp on line 4 Stack trace: #0 {main}
Process exited with code 255.
Output for 8.4.1 - 8.4.18
Fatal error: Cannot redeclare function Foo\foo() (previously declared as local import) in /in/G4ZWp on line 4
Process exited with code 255.
Output for 7.0.7 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
Fatal error: Cannot declare function Foo\foo because the name is already in use in /in/G4ZWp on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.6
int(16)
Output for 5.6.0 - 5.6.40
Parse error: syntax error, unexpected ':', expecting '{' in /in/G4ZWp on line 4
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Parse error: syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) or \\ (T_NS_SEPARATOR) in /in/G4ZWp on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_FUNCTION, expecting T_STRING or T_NS_SEPARATOR in /in/G4ZWp on line 3
Process exited with code 255.
Output for 5.2.3 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/G4ZWp on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.2
<br /> <b>Parse error</b>: syntax error, unexpected T_STRING in <b>/in/G4ZWp</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected T_STRING in <b>/in/G4ZWp</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/G4ZWp</b> on line <b>2</b><br />
Process exited with code 255.

preferences:
80.01 ms | 2678 KiB | 4 Q