3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function my_sum ($list){ $list_length = count($list); $sum = 0; for ($i = 0; $i < list_length; $i++){ print($i."<br />"); $sum = $sum + $list[$i]; return $sum; } } $list = array(5,2,3,9); $sum = my_sum($list); print("The sum of all array elements is $sum <br />"); ?>
Output for 7.2.0
Warning: Use of undefined constant list_length - assumed 'list_length' (this will throw an Error in a future version of PHP) in /in/eFolT on line 5 The sum of all array elements is <br />
Output for 4.3.0 - 7.1.10
Notice: Use of undefined constant list_length - assumed 'list_length' in /in/eFolT on line 5 The sum of all array elements is <br />