<?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 />");
?>
Fatal error: Uncaught Error: Undefined constant "i" in /in/7JQTm:6
Stack trace:
#0 /in/7JQTm(11): my_sum(Array)
#1 {main}
thrown in /in/7JQTm on line 6
Process exited with code 255.
Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/7JQTm on line 6
Notice: Undefined index: i in /in/7JQTm on line 6
The sum of all array elements is 0 <br />
Output for 7.3.32 - 7.3.33, 7.4.26
Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/7JQTm on line 6
The sum of all array elements is 0 <br />
Notice: Use of undefined constant i - assumed 'i' in /in/7JQTm on line 6
Notice: Undefined index: i in /in/7JQTm on line 6
The sum of all array elements is 0 <br />
Notice: Use of undefined constant i - assumed 'i' in /in/7JQTm on line 6
Notice: Undefined index: i in /in/7JQTm on line 6
The sum of all array elements is 0 <br />