3v4l.org

run code in 200+ 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 7.2.0 - 7.3.0rc4
0<br /> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) 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 5.3.0 - 7.1.20
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 />