我已经注意到,如果值是null
,我可以使用++$value
将其值加1,但有关减量则不正确,这意味着--$value
将返回null
,为什么?
$value = null;
echo ++$value; // 1
echo --$value; // null (I'm expecting -1)
最佳答案
Ref#language.operators.increment.php
Note: The increment/decrement operators only affect numbers and strings. Arrays, objects and resources are not affected. Decrementing NULL values has no effect too, but incrementing them results in 1.
关于php - PHP递减NULL值问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36280786/