ID: 41690 Updated by: [EMAIL PROTECTED] Reported By: ian at ithomas dot name -Status: Open +Status: Bogus Bug Type: Math related Operating System: Gentoo PHP Version: 5.2.3 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php . Previous Comments: ------------------------------------------------------------------------ [2007-06-14 14:31:02] ian at ithomas dot name Description: ------------ Incrementing null is 1. Decrementing null is null! I'm not sure which is the correct behaviour, but they should at least be consistent. I saw this on PHP 4.4.4 but have since duplicated it on 5.2.3. It was a problem for me because I had a "for ($i = null; $i > 0; $i--)" which results in an infinite loop (but would work fine if $i++ was used instead). Reproduce code: --------------- <?php echo '$i++: '; $i = null; var_dump($i); $i++; var_dump($i); echo '<br> <br> <br> $i--: '; $i = null; var_dump($i); $i--; var_dump($i); echo '<br> <br> <br> $i - 1: '; $i = null; var_dump($i); $i = $i - 1; var_dump($i); ?> Expected result: ---------------- null-- should be 1, so script should output: $i++: NULL int(1) $i--: NULL int(-1) $i - 1: NULL int(-1) Actual result: -------------- null-- is null, script output is: $i++: NULL int(1) $i--: NULL NULL $i - 1: NULL int(-1) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41690&edit=1