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 #175756 is a reply to message #175747] Sun, 23 October 2011 15:04 Go to previous messageGo to previous message
Thomas Mlynarczyk is currently offline  Thomas Mlynarczyk
Messages: 131
Registered: September 2010
Karma:
Senior Member
The Natural Philosopher schrieb:
>> // $foo = 0;
>> [1] Evaluate 0 // result: 0
>> [2] Assign result of [1] to $foo // $foo = 0
>> // $foo = ($foo++);
>> [3] Evaluate operation "post-increment" on $foo // ($foo++)
>> [3.1] Set return value to current $foo // result: 0

> Why would one do that..what 'return value' is that...

It's the result of evaluating the expression $foo++. It must remember
the current value of $foo since that is what will be needed later. Why
"one" would do that? Well, PHP needs to evaluate $foo++ somehow, how
else is it supposed to work? The above algorithm is what PHP probably
does under the hood in order to produce the observed behaviour.

> You are making the side effect of lower precedence than the bracket.

No I'm not. With the above algorithm, the side effect happens well
inside the brackets, i.e. within the evaluation of $oo++ -- that's step
[3.2] below: increment $foo while still inside the evaluation routine
[3]. At that moment, $foo = 1 and "the brackets are done", returning the
evaluation result 0 in step [3.3].

> That is NEVER done.

My sketched algorithm does produce the observed result and is consistent
with the aforementioned user comment in the PHP manual.

>> [3.2] Add 1 to $foo // $foo = 1
>> [3.3] Return result // 0
>> [4] Assign result of [3] to $foo // $foo = 0

Greetings,
Thomas

--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
[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: Thu Nov 07 22:29:07 GMT 2024

Total time taken to generate the page: 0.05396 seconds