Problems with PHP for loop: 1+2-3+4-5...+ 10
Setting $sum to zero is to initialize an integer variable, because $ sum = $ sum+($ i% 2 = =1&; & amp$ i & gt 1? (- 1)* $ I:$ I); If it is not initialized to zero, the $n of the $sum method in the first loop means 10 (1~ 10).