Re: Memory usage and refcount

From: Date: Wed, 05 Jan 2011 18:15:34 +0000
Subject: Re: Memory usage and refcount
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-51226@lists.php.net to get a copy of this message
On Wed, 2011-01-05 at 18:30 +0100, Patrick ALLAERT wrote: > <?php > 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

« previous php.internals (#51226) next »