Re: ++ BUG??
| From: | Jason | Date: | Sun, 26 Nov 2000 03:17:40 +0000 |
| Subject: | Re: ++ BUG?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27214@lists.php.net to get a copy of this message | ||
On Sun, Nov 26, 2000 at 03:22:09AM +0100, Marcin Orlowski wrote:
>
>
> Hi,
>
> This:
>
> $idx=0;
> [loop]
> {
> $idx = ($idx++)%2;
> echo $idx;
> }
>
> $idx = ($idx+1)%2;
whether there's a bug there or not, it's ambiguous code. You're doing two
assignments to $idx on the same line. $idx+1 and $idx++ are NOT equivalent.
$idx = ($idx+1)%2 is better code and you don't have to worry about the bug.