Re: $i++ problem understanding
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: $i++ problem understanding

From: lain <sh@hegi.info>
Date: Wed Oct 05 2005 - 12:04:41 CEST

Pugi! wrote:
> Currently I am studying PHP.
>
> I can understand the following :
> $a = 10;
> $b = $a++;
> print("$a, $b");
> will print 11, 10 on the screen.

just wrong.
what happens is:
$b = $a;
$a++;

so the above example actually will print ("10, 10"). understanding this
will also help you understanding the other example of yours. $a++ is
called "post increment" which means incrementing AFTER using the value
of this. of course there is also "pre increment" as of ++$a which will
do the opposite: incrementing the value and then use it for the
expression.
Received on Tue Oct 18 02:32:09 2005