3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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');
based on GqN28
Output for 7.0.0 - 7.2.0
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.3.19 - 5.6.28
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/nXa7u on line 4
Process exited with code 255.