$this return calling object.
| From: | Jochem Maas | Date: | Mon, 03 May 2004 15:50:02 +0000 |
| Subject: | $this return calling object. | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-9642@lists.php.net to get a copy of this message | ||
I have discovered behaviour which I imagine is not intended, name referencing $this in a static method that is called from a from the method of an instantiated. (see test code below.)
anyone have an explaination for $this is referencing the calling object (at least in the build I'm using)?
I'm using PHP Version 5.0.0RC3-dev on an i686 Linux box:
PHP API 20031224
PHP Extension 20040412
Zend Extension 220040412
Configure Command
'../php5-cvs/configure' '--with-interbase=shared,/opt/firebird' '--prefix=/usr' '--with-regex=system' '--with-config-file-path=/etc/php5/apache' '--enable-calendar' '--enable-ftp' '--with-gettext=shared' '--enable-sysvsem' '--enable-sysvshm' '--enable-trans-sid' '--enable-debug' '--disable-static' '--with-pcre-regex' '--enable-sockets' '--with-zlib-dir=/usr' '--enable-wddx=shared--with-imap=shared,/usr' '--with-kerberos=/usr' '--with-gd=shared,/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-freetype-dir=/usr' '--with-zlib=shared,/usr' '--with-xsl=shared,/usr' '--with-apxs=/usr/bin/apxs' '--with-interbase=/opt/interbase' '--with-interbase=/opt/interbase' '--with-gd=shared'
thanks in advance, sorry if this is misplaced.
-----
<?php
error_reporting(E_ALL & E_STRICT);
Class A {
function test() {
print_r( __CLASS__ );echo "\n";
print_r( __METHOD__ );echo "\n";
print_r( $this );echo "\n";
}
}
Class B { function test() { A::test(); } }
$b = new B();
$b->test();
?>