[thelist] [PHP] PHP5 and the use of += ?

kasimir-k kasimir.k.lists at gmail.com
Tue Aug 19 05:13:45 CDT 2008

Tris scribeva in 2008-08-19 12:40:
> The shopping basket system, currently loops through the items in the
> users basket and keeps a tally of the total cost using this:
> $finalPrice += $itemPrice;
> In each loop of the basket checker..
> However, in the new server, it seems to be adding up more than it needs to.
> As if it's doing for each loop:
> $finalPrice = $finalPrice + $finalPrice + $itemPrice;
> So the more goes into the basket, the more out ther final price is..

It would help a lot to see the code in the loop. I've got a hunch that 
it's not the
$finalPrice += $itemPrice;
which is causing the problem, but before that line $itemPrice gets a 
wrong value. Could you check the value of $itemPrice before you add it 
to the $finalPrice?

> I'm heartily confused...
> Does += work as it should in PHP5???

Yes it does.

Something else is behind this problem.


More information about the thelist mailing list