i'm playing with PHP 5.3 anonymous functions, and try to emulate the prototype based objects like javascript:
$obj = PrototypeObject::create();
$obj->word = "World";
$obj->prototype(array(
'say' => function ($ins) {
echo "Hello {$ins->word}\n";
}
));
$obj->say();
This puts "Hello World", the first param is the instance of the class (like python) but i want use the this variable, when i call function i do:
$params = array_merge(array($this),$params);
call_user_func_array($this->_members[$order], $params);
And try it, with out results:
call_user_func_array($this->_members[$order] use ($this), $params);
Too try, in __set method:
$this->_members[$var] use ($this) = $val;
And
$this->_members[$var] = $val use ($this);
Any ideas?