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

php:致命错误:访问未声明的静态属性,php,class,parent-child,parent,extends,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.p

早上好

首先,这是代码

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'
       }
    }
事实上,我需要在主菜单中添加或更改


从file browser.php

中,您似乎混淆了类和实例,您还将
main_c
视为构造函数中的数组。在将其用作数组之前,必须将其设置为数组;但是没有什么事情发生。。。。。我把它拿走了,什么也没发生