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"; } } echo RecordsToList(new ArrayObject(["Lennon", "McCartney", "Starr", "Harrison"]));
based on ZOo5b
Output for 5.5.0 - 7.0.11
Parse error: syntax error, unexpected 'Traversable' (T_STRING), expecting variable (T_VARIABLE) in /in/7GvqN on line 3
Process exited with code 255.