少し問題があります。JavaScript では、スコープを転送することが可能です:
var aaa = new function () {
that = this;
that.bbb = 'foo';
this.ccc = new function () {
this.ddd = 'bar';
this.eee = function () {
return that.bbb+this.ddd;
}
}
}
aaa.ccc.eee() は「foobar」を返します。PHPで同じ効果を得るにはどうすればよいですか? 私はコードをもっている:
class bbb {
public $ccc = 'bar';
function __construct () {
echo($that->aaa.$this->ccc);
}
}
class aaa {
public $that;
public $aaa = 'foo';
public $bbb;
function __construct () {
echo($this->aaa);
$this->$bbb = new bbb();
$this->$that = $this;
}
}
$a = new aaa ();
私はそのようなものを使用する必要があります:
$this->bbb = new bbb ($this);
class bbb {
public $that;
function __contruct ($parent) {
$that = $parent
....
}
}
?