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"; } } // Argument 1 passed to RecordsToList() must be Countable and Traversable, array given echo RecordsToList(["Lennon", "McCartney", "Starr", "Harrison"]);
based on vGA6r

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
Parse error: syntax error, unexpected 'Traversable' (T_STRING), expecting variable (T_VARIABLE) in /in/qCeXi on line 3
Process exited with code 255.
Output for Array change keys
Parse error: syntax error, unexpected 'Traversable' (T_STRING), expecting variable (T_VARIABLE) in /in/qCeXi on line 3
Process exited with code 255.
Output for Lexical anon
Parse error: syntax error, unexpected 'Traversable' (T_STRING), expecting variable (T_VARIABLE) in /in/qCeXi on line 3
Process exited with code 255.

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page