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++){ $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 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Notice: Use of undefined constant i - assumed 'i' in /in/V5aGI on line 6 Notice: Undefined index: i in /in/V5aGI on line 6 The sum of all array elements is 0 <br />
Output for 4.3.0 - 5.2.17
Notice: Use of undefined constant i - assumed 'i' in /in/V5aGI on line 6 Notice: Undefined index: i in /in/V5aGI on line 6 The sum of all array elements is 0 <br />