3v4l.org

run code in 300+ 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"; } } // Argument 1 passed to RecordsToList() must be Countable and Traversable, array given echo RecordsToList(["Lennon", "McCartney", "Starr", "Harrison"]);
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.24, 7.4.0 - 7.4.12
Parse error: syntax error, unexpected 'Traversable' (T_STRING), expecting variable (T_VARIABLE) in /in/qCeXi on line 3
Process exited with code 255.

preferences:
266.42 ms | 1396 KiB | 228 Q