Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21588 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16135 invoked by uid 1010); 20 Jan 2006 15:14:42 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 16120 invoked from network); 20 Jan 2006 15:14:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2006 15:14:42 -0000 X-Host-Fingerprint: 80.91.229.2 main.gmane.org Linux 2.5 (sometimes 2.4) (4) Received: from ([80.91.229.2:58947] helo=ciao.gmane.org) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 99/75-05698-06EF0D34 for ; Fri, 20 Jan 2006 10:14:40 -0500 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1EzxyA-0003fK-O2 for internals@lists.php.net; Fri, 20 Jan 2006 16:14:30 +0100 Received: from bos-nat1.smarterliving.net ([65.112.23.131]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 20 Jan 2006 16:14:30 +0100 Received: from rabbitt by bos-nat1.smarterliving.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 20 Jan 2006 16:14:30 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: internals@lists.php.net Date: Fri, 20 Jan 2006 10:14:16 -0500 Lines: 35 Message-ID: References: <20060120113601.GL17465@alcopop.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: bos-nat1.smarterliving.net User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050729) X-Accept-Language: en-us, en In-Reply-To: <20060120113601.GL17465@alcopop.org> Sender: news Subject: Re: [PHP-DEV] 23 nothing is so as it seems, but why From: rabbitt@xaraya.com ("Carl P. Corliss") 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. >> >>>$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