PHP Доступ к родительскому классу Переменная

class A {
    private $aa;
    protected $bb = 'parent bb';

    function __construct($arg) {
       //do something..
    }

    private function parentmethod($arg2) {
       //do something..
    }
}

class B extends A {
    function __construct($arg) {
        parent::__construct($arg);
    }
    function childfunction() {
        echo parent::$bb; //Fatal error: Undefined class constant 'bb' 
    }
}

$test = new B($some);
$test->childfunction();

Вопрос: Как мне отобразить родительскую переменную в дочернем? ожидаемый результат будет отображаться как 'parent bb'

36
задан Kuntau 23 June 2011 в 15:49
поделиться