note 37657 deleted from language.operators.increment by pollita
| From: | pollita@php.net | Date: | Sat, 22 Nov 2003 00:24:43 +0000 |
| Subject: | note 37657 deleted from language.operators.increment by pollita | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-60788@lists.php.net to get a copy of this message | ||
Note Submitter: todd@magnifisites.com
----
As stated before, the exact moment when post-increment and post-decrement happens is just
immediately after the variable is evaluated (not "after the line is processed" or
something like that). Keep this in mind during logical processing as well. If the first condition
is not met, the variable is incremented and then the next condition is tested, incrementing the
variable $i twice before continuing processing:
<?php
$i = 0;
while ($i <= 10) {
if (++$i == 1 OR ++$i % 3 === 1) print "**$i**,";
print $i . ',';
}
?>
Returns:
**1**,1,3,5,**7**,7,9,11,