Re: 23 nothing is so as it seems, but why

From: Date: Fri, 20 Jan 2006 16:47:28 +0000
Subject: Re: 23 nothing is so as it seems, but why
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-21590@lists.php.net to get a copy of this message
Guys, please take this offlist. Undefined means undefined. There's no assumed way of it working. Andi At 07:14 AM 1/20/2006, Carl P. Corliss wrote:
Jon Dowland wrote:
On Thu, Jan 19, 2006 at 06:41:17PM +0200, Marco Kaiser wrote:
Today during a session i had a strange "magic" feature found in php. <?php $a = 10; echo ++$a + $a++; ?> this works perfect as expected. it returns 22.
Odd, I expected 21:
        echo (11 + 10)
        a = a + 1
nope - discounting the 'undefined behavior' of using pre/post increment operators, 22 would be the correct assumption - remember, broken into seperate statements, it's effectively: $a = 10; $a = $a + 1; // $a == 11
$a + $a;     // $a == 22
echo $a; $a = $a + 1; // $a == 23 Cheers, -- Carl -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#21590) next »