Posted by lain on 10/13/81 11:28
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.
Navigation:
[Reply to this message]
|