FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » simple session question
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: OT: and even in Dart .........Re: simple session question [message #175750 is a reply to message #175734] Sun, 23 October 2011 08:39 Go to previous messageGo to previous message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma:
Senior Member
In article <j7vhmk$420$1(at)news(dot)albasani(dot)net>,
Thomas Mlynarczyk <thomas(at)mlynarczyk-webdesign(dot)de> wrote:

> Norman Peelman schrieb:
>
>> $foo = 0;
>> $foo = $foo++;
>>
>> It should be equivalent to:
>>
>> $foo = 0; // 0
>> $foo = $foo; // 0 = 0
>> $foo = $foo + 1; // 0 = (0 + 1)
>
> No. What you are doing here is assigning first and then incrementing.
> The evaluation of $foo++ returns 0 and increments $foo as a side effect.
> This evaluation process must be completed before the assignment can happen:
>
> [1] Evaluate the expression $foo++ (result: 0, side effect: $foo = 1)
> [2] Assign the result to $foo ($foo = 0)
>
>> $foo++ means that the variable is to be incremented after the variable
>> is accessed.
>
> Yes, it means that the expression $foo++ evaluates to the value which
> $foo had before. And it is this value which is assigned to $foo after
> the $foo++ step is completed.

Yes - as per my JavaScript example. If I say:

results[i++];

I get the value of results[i]. That value is held in limbo to be
assigned to the LHS. Then the post-increment occurs. Then the result
from limbo is assigned to LHS.

And so with PHP. Which will mean that:

$foo = $foo++;
$foo = ($foo++);

both act the same and set $foo to 0.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: session cookie: client side
Next Topic: by get this format my explode file name like this through php
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Dec 22 02:07:32 GMT 2024

Total time taken to generate the page: 0.04445 seconds