Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51226 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38080 invoked from network); 5 Jan 2011 18:15:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jan 2011 18:15:52 -0000 Authentication-Results: pb1.pair.com header.from=johannes@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 217.114.211.66 as permitted sender) X-PHP-List-Original-Sender: johannes@php.net X-Host-Fingerprint: 217.114.211.66 unknown Solaris 10 (beta) Received: from [217.114.211.66] ([217.114.211.66:63524] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 58/0B-10843-C45B42D4 for ; Wed, 05 Jan 2011 13:15:51 -0500 Received: from [192.168.2.189] (ppp-93-104-125-137.dynamic.mnet-online.de [93.104.125.137]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id 19E844BFD1; Wed, 5 Jan 2011 19:15:37 +0100 (CET) To: Patrick ALLAERT Cc: PHP Development In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Organization: php.net Date: Wed, 05 Jan 2011 19:15:34 +0100 Message-ID: <1294251334.5055.52.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.2 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Memory usage and refcount From: johannes@php.net (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Wed, 2011-01-05 at 18:30 +0100, Patrick ALLAERT wrote: > class foo { > static function def() { > // $x as a static *function* var > static $x = "foo"; > return $x; $x is a reference to the static variable. It has to since assignment to $x, which is a local variable, should change the static variable. This is returned using copy semantis so we can't do copy on write. Whereas with > class foo { > // $x as a static *class* var > static $x = "foo"; > static function def() { > return self::$x; > } > } you are explicitly referencing the static class property. CoW can work properly. johannes