+ 2
module 6
Can someone explain me step by step? What output results from the following code? function func($arg) { $result = 0; for($i=0; $i<$arg; $i++) { $result = $result + $i; } return $result; } echo func(5); //10 why? how?
1 ответ
+ 4
Cycle 1:
result = 0 + i(0)
Cycle 2:
result = 0 + i(1)
Cycle 3:
result = 1 + i(2)
Cycle 4:
result = 3 + i(3)
Cycle 5
result = 6 + i(4)
Result = 10