From:             [EMAIL PROTECTED]
Operating system: Linux
PHP version:      4.0CVS-2002-04-19
PHP Bug Type:     *Math Functions
Bug description:  %= operator

I've tried a trick I often use in C++; the PHP syntax should be identical:

$a=0;
while ([condition]) {
  $mystring= ++$a%=8 ? "A" : "B";
  [...]
}

the value of $mystring should be "B" seven times and then "A" once,
keeping the value of $a in the range [0..7].

If $a is useless for other purposes, the following gives the same result:

$a=0;
while ([condition]) {
  $mystring= ++$a%8 ? "A" : "B";
  [...]
}

whith two differences:
$a is no loger necessarily in the range [0..7] and, above all, tha latter
works, but tha former doesn't!

I've tried to parse "++$a" writing
  $mystring= (++$a)%=8 ? "A" : "B";

but it doesn't work.

Since this problem is related to operators, I don't think you need
information about my modules or my system, but if I'm wrong ask me for
that.
Thank you.

Regards,

Davide Spagnoli
-- 
Edit bug report at http://bugs.php.net/?id=16697&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=16697&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=16697&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=16697&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=16697&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=16697&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=16697&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=16697&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=16697&r=submittedtwice

Reply via email to