- Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.21, 7.0.0 - 7.0.6
- Parse error: syntax error, unexpected 'Traversable' (T_STRING), expecting variable (T_VARIABLE) in /in/vGA6r on line 3
Process exited with code 255.
<?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(["Lennon", "McCartney", "Starr", "Harrison"]);