Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21584 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51907 invoked by uid 1010); 19 Jan 2006 20:42:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 51892 invoked from network); 19 Jan 2006 20:42:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2006 20:42:59 -0000 X-Host-Fingerprint: 195.197.172.111 gw03.mail.saunalahti.fi Linux 2.4/2.6 Received: from ([195.197.172.111:37036] helo=gw03.mail.saunalahti.fi) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 6C/0B-03850-2D9FFC34 for ; Thu, 19 Jan 2006 15:42:59 -0500 Received: from nest.netphobia.fi (YZDCXXXI.dsl.saunalahti.fi [85.76.35.232]) by gw02.mail.saunalahti.fi (Postfix) with ESMTP id 00526E75EF; Thu, 19 Jan 2006 22:42:52 +0200 (EET) Received: from nest.netphobia.fi (nest.netphobia.fi [127.0.0.1]) by nest.netphobia.fi (8.13.1/8.13.1) with ESMTP id k0JKgtas030581; Thu, 19 Jan 2006 22:42:55 +0200 Received: from localhost (jani@localhost) by nest.netphobia.fi (8.13.1/8.13.1/Submit) with ESMTP id k0JKgsm2030578; Thu, 19 Jan 2006 22:42:54 +0200 X-Authentication-Warning: nest.netphobia.fi: jani owned process doing -bs Date: Thu, 19 Jan 2006 22:42:54 +0200 (EET) Reply-To: Jani Taskinen To: Marco Kaiser cc: internals@lists.php.net In-Reply-To: Message-ID: References: <1855654224.20060119205358@marcus-boerger.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Subject: Re: [PHP-DEV] 23 nothing is so as it seems, but why From: sniper@iki.fi (Jani Taskinen) For the 2nd time: references ARE NOT POINTERS! :-p --Jani On Thu, 19 Jan 2006, Marco Kaiser wrote: > Hmm yes i know this, > but its very interesting for me to see how php internaly handles ++$a with a > pointer. > Now i understand it :) > > -- Marco > > 2006/1/19, 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 >> >> > > > -- > Marco Kaiser > -- Give me your money at @ Donating money may make me happier and friendlier for a limited period! Death to all 4 letter abbreviations starting with P!