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-16 12:54:08] ian at ithomas dot name

Sorry, forgot to reopen it. See comment above for why.

------------------------------------------------------------------------

[2007-06-14 15:46:55] ian at ithomas dot name

Thanks for your response. Since filing this I've found
http://uk2.php.net/manual/en/language.operators.increment.php which
states:

"Decrementing NULL values has no effect too, but incrementing them
results in 1."

but with no further explanation. I assume it is because this behaviour
is documented that you are saying that this is not a bug.


This behaviour is counter-intuitive, so unless there is a good reason
for it (which should be mentioned in the documentation) it remains a
bug. Documenting a bug doesn't fix it!

------------------------------------------------------------------------

[2007-06-14 15:39:36] [EMAIL PROTECTED]

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

.

------------------------------------------------------------------------

[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

Reply via email to