3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $list=array(5,2,3,9); function my_sum ($list){ $count = 0; for ($i=0; $i<= Array_count_values($list); $i++){ print($i."<br />"); $count = $count + $list[i]; return $count; } } $sum = my_sum($list); print("The sum of all array elements is $sum <br />"); ?>
Output for 5.3.0 - 7.1.0
0<br /> Notice: Use of undefined constant i - assumed 'i' in /in/qSdRb on line 7 Notice: Undefined index: i in /in/qSdRb on line 7 The sum of all array elements is 0 <br />
Output for 4.3.0 - 5.2.17
0<br /> Notice: Use of undefined constant i - assumed 'i' in /in/qSdRb on line 7 Notice: Undefined index: i in /in/qSdRb on line 7 The sum of all array elements is 0 <br />