class m {
public $mA ;
public $mB ;
function __construct(){
$this->mA = new a();
$this->mB = new b();
}
}class a {
public $a01 = "";
public $a02 = "";
function __construct(){
$this->a01 = "111";
$this->a02 = "222";
}
}class b {
function __construct(){
echo "start Class B"."<BR>";
//这里输出class A的属性$a01
}
}new m();
怎样在class B里面获得class A里面的属性?
public $mA ;
public $mB ;
function __construct(){
$this->mA = new a();
$this->mB = new b();
}
}class a {
public $a01 = "";
public $a02 = "";
function __construct(){
$this->a01 = "111";
$this->a02 = "222";
}
}class b {
function __construct(){
echo "start Class B"."<BR>";
//这里输出class A的属性$a01
}
}new m();
怎样在class B里面获得class A里面的属性?
class m {
public $mA ;
public $mB ;
function __construct(){
$this->mA = new a();$this->mB = new b($this);
}
} class a {
public $a01 = "";
public $a02 = "";
function __construct(){
$this->a01 = "111";
$this->a02 = "222";
}
} class b {
function __construct($_mpointer=''){echo "start Class B"." <BR>";
if(is_object($_mpointer)) echo $_mpointer->mA->a01;}
}
$m = new m();
运算中class A属性改变了 class B取到的是改变前的值5楼:
用到的时候new的和之前在class M里面new的是两个实例化对象,两个对象的属性值可能会相同吗?