1) Why can't I use '$this' since when $func() is executed it will be in foo's object context ? (So $this should be available ?!)
2) How can I avoid this problem ? (cause I really need to call a function from class foo)
Quote:
class foo{
public function internal(){
print 'Hello world.';
}
public function __call($method, $args){
if(isset($this->$method)){
$func = $this->$method;
$func();
}
}
}
$f = new foo();
$f->bar = function () {$this->internal();};
$f->bar();
|