note 75755 added to language.operators.increment

From: Date: Thu, 14 Jun 2007 14:34:58 +0000
Subject: note 75755 added to language.operators.increment
Groups: php.notes 
Request: Send a blank email to php-notes+get-127477@lists.php.net to get a copy of this message
As the manual says, decrementing NULL in this way yields NULL, although incrementing it yields 1, as you might expect. Can't quite see why this makes sense, but if you need to work around it, you can use '-= 1' instead: <?php $i = null; --$i; var_dump($i); // NULL $i--; var_dump($i); // NULL $i-=1; var_dump($i); // int(-1) ?> Note that -= returns the value assigned, so treat it like '--$i', not '$i--' if you're testing the value. ---- Server IP: 194.145.210.3 Probable Submitter: 217.154.203.18 ---- Manual Page -- http://www.php.net/manual/en/language.operators.increment.php Edit -- https://master.php.net/note/edit/75755 Del: integrated -- https://master.php.net/note/delete/75755/integrated Del: useless -- https://master.php.net/note/delete/75755/useless Del: bad code -- https://master.php.net/note/delete/75755/bad+code Del: spam -- https://master.php.net/note/delete/75755/spam Del: non-english -- https://master.php.net/note/delete/75755/non-english Del: in docs -- https://master.php.net/note/delete/75755/in+docs Del: other reasons-- https://master.php.net/note/delete/75755 Reject -- https://master.php.net/note/reject/75755 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127477) next »