我是 php 新手,所以问题是转储。看看下面的代码
class A {
private $obj;
public function A() {
$this->obj = new Obj();
//$this->obj->fff() works here;
//still var_dump($this->obj) prints NULL here
}
public f() {
//$this->obj is NULL here!!!
//$this->obj->ff() throws an error
}
}
UPD在f()
我得到Fatal error: Call to a member function ff() on a non-object in ...
我应该如何初始化$obj
才能看到它f()
?
先感谢您!!