Hi,

$this stays defined when an instantatiated member function calls a
non-instantiated member function.

Here's the tester:

<?php

class a {
        function test() { var_dump($this); }
        function objtest($obj) { $obj->test(); }
        function btest() { b::test(); }
}

class b {
        function test() { var_dump($this); }
        function objtest($obj) { $obj->test(); }
        function atest() { b::test(); }
}

print "A::test:\n";
a::test();
print "A::btest:\n";
a::btest();
print "B::test:\n";
b::test();
print "B::atest:\n";
b::atest();

$a = new a;
$b = new b;
print "\$A->test:\n";
$a->test();
print "\$A->btest:\n";
$a->btest();
print "\$A->objtest(\$B):\n";
$a->objtest($b);
print "\$B->test:\n";
$b->test();
print "\$B->atest:\n";
$b->atest();
print "\$B->objtest(\$A):\n";
$b->objtest($a);
?>

Sample output (php-4.3.0RC2, compiled with ./configure; make):

kotta:~/src/php-4.3.0RC2>>% ./sapi/cli/php ~/test.php
A::test:
NULL
A::btest:
NULL
B::test:
NULL
B::atest:
NULL
$A->test:
object(a)(0) {
}
$A->btest:
object(a)(0) {
}
$A->objtest($B):
object(b)(0) {
}
$B->test:
object(b)(0) {
}
$B->atest:
object(b)(0) {
}
$B->objtest($A):
object(a)(0) {
}


-- 
jul

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to