3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class FifaRankingHeap extends \SplHeap { protected function compare($value1, $value2) { return $value1['points'] - $value2['points']; } } $heap = new FifaRankingHeap(); $heap->insert(array('country' => 'Colombia', 'points' => 1137)); $heap->insert(array('country' => 'Uruguay', 'points' => 1147)); $heap->insert(array('country' => 'Argentina', 'points' => 1175)); $heap->insert(array('country' => 'Brazil', 'points' => 1242)); $heap->insert(array('country' => 'Portugal', 'points' => 1189)); $heap->insert(array('country' => 'Germany', 'points' => 1300)); $heap->insert(array('country' => 'Switzerland', 'points' => 1149)); $i = 2; foreach ($heap as $country) { echo $i++.$country['country'].' has '.$country['points'].' points.<br>'; }
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
2Germany has 1300 points.<br>3Brazil has 1242 points.<br>4Portugal has 1189 points.<br>5Argentina has 1175 points.<br>6Switzerland has 1149 points.<br>7Uruguay has 1147 points.<br>8Colombia has 1137 points.<br>
Output for 5.0.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/9X9VC on line 3 Fatal error: Class 'SplHeap' not found in /in/9X9VC on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/9X9VC on line 3 Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9X9VC on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/9X9VC on line 3 Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9X9VC on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/9X9VC on line 3 Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/9X9VC on line 4
Process exited with code 255.