From:             [EMAIL PROTECTED]
Operating system: Linux 2.2
PHP version:      4.0.4pl1
PHP Bug Type:     Scripting Engine problem
Bug description:  Static classes sometimes have a $this pointer

If you call a static method from within an object, the static method will inherit the 
$this pointer of the calling object. This script demonstrates the problem:

<?php

error_reporting(E_ALL);

class StaticClass {
    function doSomething() {
        echo $this->data;
    }
}

class Instantiated {
    var $data;

    function Instantiated($data) {
        $this->data = $data;
        StaticClass::doSomething();
    }
}

$ob = new Instantiated('foo');

?>


This is rather confusing behavior - $this should be out of scope inside static methods 
no matter what.



-- 
Edit Bug report at: http://bugs.php.net/?id=9005&edit=1



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to