How to declare anonymous function write in C for PHP extension?

72 views Asked by At

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?

0

There are 0 answers