Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44024 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36005 invoked from network); 18 May 2009 12:29:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 May 2009 12:29:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=rewbs.soal@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rewbs.soal@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.221.107 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rewbs.soal@gmail.com X-Host-Fingerprint: 209.85.221.107 mail-qy0-f107.google.com Received: from [209.85.221.107] ([209.85.221.107:44839] helo=mail-qy0-f107.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 20/02-25779-5C4511A4 for ; Mon, 18 May 2009 08:29:57 -0400 Received: by qyk5 with SMTP id 5so700105qyk.29 for ; Mon, 18 May 2009 05:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:reply-to:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=PY5lDa1une0F9puHGw2UVFVXYNIbNpj6jK4WtK7kmyI=; b=rSq8QpT9PoFq4i61yln9f/wCWDLw1TvYDjTYcuOaf408i6kRfiHusjT7fwToRpWbOd dzZzncRSTDzo7HXtX0zFdFOrSZuE6oGhBB1zKTYImHEarVOz8pc3x/ApzYmfk8+Z83vw QoNsrUfdpes02e8Ml/GxG7zHQpBimDn5vD8UY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:content-type:content-transfer-encoding; b=ES35coHO7piVAj2MgRrxF15WH/+0mTdfuOUArGSMHf9EuNZ0XlzhLINrC0VnPIv00O kqI3S7EwA/u26I9EZNuIrgK+V/h968eGf08ncIYoA2oWAHAmBRP3pjPZF58l8R08cgoY L3ttI56Oz6J8E55mAbjftDkfV+UFkV0JqJFQ4= MIME-Version: 1.0 Received: by 10.229.100.81 with SMTP id x17mr2998965qcn.15.1242649795249; Mon, 18 May 2009 05:29:55 -0700 (PDT) Reply-To: robin@soal.org In-Reply-To: References: Date: Mon, 18 May 2009 13:29:35 +0100 Message-ID: <5a8807d10905180529j1950344ayb3ee6de8f1a0d717@mail.gmail.com> To: Jingcheng Zhang , php-dev Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Suggestion on static field inheritance From: rewbs.soal@gmail.com (Robin Fernandes) 2009/5/16 Jingcheng Zhang : > > Maybe I have not found its detailed description on PHP's official manual, > but PHP does allow static field inheritance. However there is a little > difference between dynamic field inheritance and static field inheritance, > as the following codes shows: Hi! I think the current behaviour is as expected. In that example, there is a single static field which is shared between classes static_a, static_b and static_c. Because there is just one value of $name, the class through which you access the value makes no difference. On the other hand, in the case of classes dynamic_a, dynamic_b and dynamic_c, by the nature of instance properties, each instance has its own value of $name. So changing the value in one instance does not affect the others. This behaviour is similar to many other OO languages, including Java, C++ and C#. Perhaps a closer equivalent of the Javascript code you provided is as follows, where the static field is re-declared in subclasses, and therefore exists as a separate entity in each class. Again, this distinction between inherited static fields and "re-declared" static fields also applies to other languages such as Java, C++ and C#. What do you think? Regards, Robin