3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Liam { public function __construct() { $this->printString(); $this->printArray(); } public function printString(string $prefix) : string { print $this->_generateString(); } public function printArray(array $array) : array { print array(); } private function _generateString() : string { return random(1,255); } } print_r(new Liam());
Output for 7.1.0 - 7.1.25, 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Liam::printString(), 0 passed in /in/aa44t on line 5 and exactly 1 expected in /in/aa44t:9 Stack trace: #0 /in/aa44t(5): Liam->printString() #1 /in/aa44t(23): Liam->__construct() #2 {main} thrown in /in/aa44t on line 9
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Fatal error: Uncaught TypeError: Argument 1 passed to Liam::printString() must be of the type string, none given, called in /in/aa44t on line 5 and defined in /in/aa44t:9 Stack trace: #0 /in/aa44t(5): Liam->printString() #1 /in/aa44t(23): Liam->__construct() #2 {main} thrown in /in/aa44t on line 9
Process exited with code 255.
Output for 5.4.9 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/aa44t on line 9
Process exited with code 255.

preferences:
228.91 ms | 402 KiB | 235 Q