I have the following code:
class Demo
{
private $data = array();
public function foo($key, $value)
{
$this->data[$key] = function ($c) use ($value) {
return $c + $value;
});
}
}
As you can see the foo
method sets the $key
using an anonymous function. And it uses the use($value)
syntax.
How to achieve this in a PHP extension?