php:致命错误:访问未声明的静态属性

时间:2015-12-11 23:48:18

标签: php class parent-child parent extends

早上好

第一个是代码

loader.php

class loader{
  public $main_c;
  function __construct(){
    $this->main_c['one']=array("a","b","c");
    $this->main_c['two']=array("e","f","g");
    $this->loadtwo();
  }
  function loadtwo(){
   require_once(home.php);
   $browser=new browser();
   $browser->add();
  }
}
 $loader=new loader();

home.php

class browser extends loader{

function __construct(){ 
   print $this->main_c;    //empty value
}

function add(){
        print parent::$main_c //Fatal error: Access to undeclared static     property: loader::$main_c
         print parent::main_c; //Fatal error: Undefined class constant 'main_c'
       }
    }

事实上我需要在main_c中添加或更改

来自文件browser.php

0 个答案:

没有答案