Maybe I'm doing something wrong, but I have some code similar to this...

<?php
class a {
    function printme() {
        return 'hello world';
    }
}

class foo {
    protected static $blort = null;

    function __construct() {
        if (self::$blort == null)
            self::$blort = new a;
    }
}

class bar extends foo {
    function __construct() {
        parent::__construct();
        var_dump(self::$blort);
        var_dump(self::$blort->printme());
    }
}

$b = new bar;
?>

Which gives me: 

NULL

Fatal error: Call to a member function printme() on a non-object in 
/home/jay/static.php on line 22

Seems that the static property $blort in foo is getting lost somewhere.

Meanwhile, accessing $blort in the parent class via parent::$blort gives a 
"Cannot access protected property" error.

Am I doing something wrong here, expecting the wrong behaviour, or is this a
bug?

J

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

Reply via email to