note 114022 deleted from language.operators.increment by tularis

From: Date: Thu, 02 Jan 2014 11:59:57 +0000
Subject: note 114022 deleted from language.operators.increment by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198078@lists.php.net to get a copy of this message
Note Submitter: Putu Oka Warma Kurniawan ---- Note: use ++$x instead of $x++ for the "for loop" statement i have a problem before when i tried my code on my localhost and upload it to the server. it's give me different result when you use $x++ in for statement and upload your code to the server hosting. this for loop statement will give you more than 20 loops. <?php ... for($x=0; $x<=20; $x++){ //statement } ... ?> the $x variable will not increasing properly. for example when $x=7 then next loop it should be $x=$x+1 = 8 but with $x++ for loop statement it will give you random $x value it can be $x=0 again and continue increasing randomly. but with this will make your code run fine <?php ... for($x=0; $x<=20; ++$x){ //statement } ... ?> strange increment behavior. i realize it for a day

« previous php.notes (#198078) next »