Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10693 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 28639 invoked by uid 1010); 21 Jun 2004 16:34:55 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 28595 invoked by uid 1007); 21 Jun 2004 16:34:55 -0000 Message-ID: <20040621163454.28593.qmail@pb1.pair.com> To: internals@lists.php.net, Ard Biesheuvel Date: Mon, 21 Jun 2004 18:34:45 +0200 References: <20040621125401.81779.qmail@pb1.pair.com> Lines: 61 User-Agent: KNode/0.7.6 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Posted-By: 84.128.41.58 Subject: Re: behaviour of static calls to regular methods From: schlueter@phpbar.de (Johannes Schlueter) Hi, yes, afaik it's intentional. This was made for making parent::foo() work. Here's a shorter (at least a bit shorter *g*) example of this behavior: a(); // Calls bar::b() ?> Prints: object(foo)#1 (0) { } So in a static call $this holds the instance of the calling object. johannes Ard Biesheuvel wrote: > > Is the fact that the following code works intentional ? > > class S { > function func() { > A::meth(); > } > } > > class A { > private $bar; > > function meth() { > $this->bar="bar"; > } > > function func() { > S::func(); > echo "$this->bar\n"; > > } > } > > > $a = new A; > $a->func(); > > ... so A::$this is accessed through two static calls to different classes. >