can you post something that would run on php?



Larry Brown wrote:

Apparently I'm having some kind of meltdown here.  Can anyone explain the
logic behind why the following variable has the original value and how I can
pull/push the value to access it at the end?


while loop { $variable = 100; while loop { switch($othervar) { case 1: $variable = $variable + 100; break; case 2: $variable = $variable + 200; break; case 3: $variable = $variable + 300; break; } echo $variable."<br>"; } echo "<br>The final value is ".$variable."<br>"; }

This gives values something to the tune of...

200
400
700

100

I usually have variables set outside of a while loop that increment based on
the contents of the loop and I could swear that they hold the value on the
other side of the loop.  I don't usually use break; in my scripts unless I'm
using switch. However, I would think that if using break was throwing me,
that the value wouldn't print on each cycle of the loop.

TIA

Larry

-- André Cerqueira

Attachment: signature.asc
Description: OpenPGP digital signature



Reply via email to