Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21582 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26286 invoked by uid 1010); 19 Jan 2006 19:56:03 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 26270 invoked from network); 19 Jan 2006 19:56:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2006 19:56:02 -0000 X-Host-Fingerprint: 81.169.182.136 ajaxatwork.net Linux 2.4/2.6 Received: from ([81.169.182.136:56676] helo=strato.aixcept.de) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id C3/47-03850-0DEEFC34 for ; Thu, 19 Jan 2006 14:56:01 -0500 Received: from [192.168.1.3] (dslb-084-063-002-198.pools.arcor-ip.net [84.63.2.198]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id 975BE35C1DD; Thu, 19 Jan 2006 20:55:56 +0100 (CET) Date: Thu, 19 Jan 2006 20:53:58 +0100 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <1855654224.20060119205358@marcus-boerger.de> To: Marco Kaiser Cc: internals@lists.php.net In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] 23 nothing is so as it seems, but why From: helly@php.net (Marcus Boerger) Hello Marco, though Hartmut is perfectly correct in his statement here's what happens: $a = 10; // 10 ++$a // 11 $a + $a // 22 $a++ // 23 Thursday, January 19, 2006, 5:41:17 PM, you wrote: > Today during a session i had a strange "magic" feature found in php. > $a = 10; > echo ++$a + $a++; ?>> just to verfiy echo $a after your echo line, it will show 12 > this works perfect as expected. it returns 22. > but if i assign $a as a ref. to another variable it will be return 23. > $a = 10; > $b = &$a; > echo ++$a + $a++; ?>> > this will gave me to 23 > (used the $b to the pre post stuff) > $a = 10; > $b = &$a; > echo ++$b + $b++; ?>> > this just happens if i have a ref. count to my var. WHY? :) > http://en.wikipedia.org/wiki/23_%28film%29 > -- > Marco Kaiser Best regards, Marcus