Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19726 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69844 invoked by uid 1010); 26 Oct 2005 13:12:07 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 69829 invoked from network); 26 Oct 2005 13:12:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Oct 2005 13:12:07 -0000 X-Host-Fingerprint: 64.233.184.193 wproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.184.193:12446] helo=wproxy.gmail.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id D5/70-22886-6A08F534 for ; Wed, 26 Oct 2005 09:12:07 -0400 Received: by wproxy.gmail.com with SMTP id 71so57414wra for ; Wed, 26 Oct 2005 06:12:03 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Lzq5LHuxs33aISDWaaO1XjfDtCLVo2lK9rsw59nQu31NApRjyIGd7HZCrWxPqp//6LumiZRevHeCgEAueef2CTep26Cr20TqYDnZXqxDvQwJ8JlvZ6qdFHSpoR28unUljDyRYQo85JU+hEP30yLKsaeZEquvQvGIeBtAABeVar0= Received: by 10.54.16.72 with SMTP id 72mr412355wrp; Wed, 26 Oct 2005 06:12:03 -0700 (PDT) Received: by 10.54.76.6 with HTTP; Wed, 26 Oct 2005 06:12:03 -0700 (PDT) Message-ID: <4e89b4260510260612i6430706bw6ff4b7d909fc9c40@mail.gmail.com> Date: Wed, 26 Oct 2005 09:12:03 -0400 To: Matthias Pigulla Cc: internals@lists.php.net In-Reply-To: <00A2E2156BEE8446A81C8881AE117F192C183E@companyweb> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <00A2E2156BEE8446A81C8881AE117F192C183E@companyweb> Subject: Re: [PHP-DEV] Questions about "static" and serialization From: kingwez@gmail.com (Wez Furlong) As you mentioned, static properties and statically scoped variables don't belong to an object instance, so it doesn't make sense to serialize them. --Wez. On 10/26/05, Matthias Pigulla wrote: > Hi internals, > > I was experimenting with different approaches of maintaining state and > serializing objects in PHP5. The problem is handling static class > members and static variables inside methods. > > First, I noted that static variables inside methods are shared between > instances. C++ seems to handle it the same way, but admittedly, I was a > little bit surprised: Such variables are available as "local" variables > in methods that are called using an instance, i. e. non-statically, > whereas static class variables can only be accessed using a static > reference to a class (self::, parent:: or Classname::). > > However, this explains why static variables inside functions do not show > up when serializing object instances: Because the static variable is - > just like a static class variable - not "part of the object", but > belongs to the class. > > So - has anybody ever considered serializing static variables as well? > Obviously they have to be treated separately at a per-class level; let > alone static variables in functions outside classes ;). > > Would it be possible to write a session serialize handler that somehow > includes such static elements? I presume it should be possible to > "somewhere find" the static elements. > > (Strictly spoken, an object instance's state expresses itself in > non-static members of the instance, so the above "static variables in > functions" stuff makes sense the way it is - if I want to maintain > per-instance state, I shouldn't be using local static variables, but > "plain" object members for that. However, when working with the > Singleton pattern, you don't come around using static at some level...) > > Best regards, > Matthias > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >