3v4l.org

run code in 200+ PHP versions simultaneously
<?php function RecordsToList(Countable & Traversable $input): String { if (count($input) > 0) { $output = "<ol>\n"; foreach ($input as $value) { $output .= "\t<li>" . htmlentities($value) . "</li>\n"; } $output .= "</ol>\n"; return $output; } else { return "<p>No items to display.</p>\n"; } } // Fatal error: Uncaught TypeError: Argument 1 passed to RecordsToList() must be Countable and Traversable, array given, called in %s on line %d echo RecordsToList(["Lennon", "McCartney", "Starr", "Harrison"]);
based on quLbJ
Output for 5.5.0 - 7.0.6
Parse error: syntax error, unexpected 'Traversable' (T_STRING), expecting variable (T_VARIABLE) in /in/ZOo5b on line 3
Process exited with code 255.