0
나는 "WORKED"를 반환 할 것으로 기대되는 코드를 가지고 있지만 아무것도 반환하지 않습니다.클래스 계층
class Foo {
public function __construct() {
echo('Foo::__construct()<br />');
}
public function start() {
echo('Foo::start()<br />');
$this->bar = new Bar();
$this->anotherBar = new AnotherBar();
}
}
class Bar extends Foo {
public function test() {
echo('Bar::test()<br />');
return 'WORKED';
}
}
class AnotherBar extends Foo {
public function __construct() {
echo('AnotherBar::__construct()<br />');
echo($this->bar->test());
}
}
$foo = new Foo();
$foo->start();
라우터 :
Foo::__construct() <- From $foo = new Foo();
Foo::start() <- From Foo::__construct();
Foo::__construct() <- From $this->bar = new Bar();
AnotherBar::__construct() <- From $this->anotherBar = new AnotherBar();
내가 Foo
클래스에서 $bar
을 정의하고, Foo
에 AnotherBar
, 나는 이미 Foo
에서 정의 된 변수를 얻을 것으로 예상 확장 때문에
나는 무엇이 잘못되었는지를 볼 수 없습니다. 어디에서 캠 시작합니까?
감사합니다.
예,이 오류에 대해 알고 있습니다. 내 질문이 업데이트 될 것입니다. –
질문이 업데이트되었습니다. –