note 97872 added to language.operators.increment
| From: | EzekielVictor at osu1 dot php dot net | Date: | Thu, 13 May 2010 07:04:46 +0000 |
| Subject: | note 97872 added to language.operators.increment | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-169203@lists.php.net to get a copy of this message | ||
Knowing nothing about how PHP implements these operators, it appears to me that dsbeam's tests
below yield a logical result. After all, in order for the post-increment/post-decrement operators to
return the initial value *before* the operation occurs, I would think the operators must use a small
amount of memory to store the initial value before performing the operation. Otherwise, the initial
value wouldn't be available to return after the operation.
Here's a pseudo code example of how pre- and post-increment operators might be implemented:
operator ++() // pre-increment
increment value
return value
operator ++(int) // post-increment
store value
increment value
return stored value from before increment
----
Server IP: 69.147.83.197
Probable Submitter: 98.151.254.181
----
Manual Page -- http://www.php.net/manual/en/language.operators.increment.php
Edit -- https://master.php.net/note/edit/97872
Del: integrated -- https://master.php.net/note/delete/97872/integrated
Del: useless -- https://master.php.net/note/delete/97872/useless
Del: bad code -- https://master.php.net/note/delete/97872/bad+code
Del: spam -- https://master.php.net/note/delete/97872/spam
Del: non-english -- https://master.php.net/note/delete/97872/non-english
Del: in docs -- https://master.php.net/note/delete/97872/in+docs
Del: other reasons-- https://master.php.net/note/delete/97872
Reject -- https://master.php.net/note/reject/97872
Search -- https://master.php.net/manage/user-notes.php