3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ICommand { public function execute() : string; } class Test { public function execute(string $val) : int { return 'asd ' . $val; } } $t = new Test(); echo $t->execute('sample val');
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught TypeError: Test::execute(): Return value must be of type int, string returned in /in/nXa7u:9 Stack trace: #0 /in/nXa7u(14): Test->execute('sample val') #1 {main} thrown in /in/nXa7u on line 9
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Return value of Test::execute() must be of the type int, string returned in /in/nXa7u:9 Stack trace: #0 /in/nXa7u(14): Test->execute('sample val') #1 {main} thrown in /in/nXa7u on line 9
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
Fatal error: Uncaught TypeError: Return value of Test::execute() must be of the type integer, string returned in /in/nXa7u:9 Stack trace: #0 /in/nXa7u(14): Test->execute('sample val') #1 {main} thrown in /in/nXa7u on line 9
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/nXa7u on line 4
Process exited with code 255.

preferences:
250.42 ms | 402 KiB | 330 Q