I have two classes :
class A {
public function load() {
$var = new some_class();
return $var;
}
}
and
class B extends A {
public function test() {
$this->load();
$var->some_method(); // ERROR : variable "$var" does not exists
}
}
I want to access the local variable $var
of the class "A" from class "B", how can i do this?
just fill $var with $this->load();
class B extends A {
public function test() {
$var = $this->load();
$var->some_method(); // WORKS
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.