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 #175744 is a reply to message #175734] Sun, 23 October 2011 02:52 Go to previous messageGo to previous message
Norman Peelman is currently offline  Norman Peelman
Messages: 126
Registered: September 2010
Karma:
Senior Member
On 10/22/2011 06:56 PM, Thomas Mlynarczyk 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.
Yes

> The evaluation of $foo++ returns 0 and increments $foo as a side effect.
Yes

> This evaluation process must be completed before the assignment can happen:
Yes

>
> [1] Evaluate the expression $foo++ (result: 0, side effect: $foo = 1)
Yes

> [2] Assign the result to $foo ($foo = 0)

But when you echo $foo on the next line it should equal 1. It's a
race condition as 0 is held in a temporary buffer, $foo is incremented,
and then $foo is assigned the temporary buffer. Thereby overwriting the
increment.


>
>> $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.
>

Not really *before*, i'd say *current* value.

> Greetings,
> Thomas
>
>


--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
[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 08:27:55 GMT 2024

Total time taken to generate the page: 0.05803 seconds