Anonymous functions in a class
<p>is there a better way to call an anonymous function inside a class? Here is a simple example that clearifies what I mean.</p>

<pre><code>class foo
{
     private $call_back_1 = null;
     private $call_back_2 = null;

     function __construct($func1, $func2)
     {
          $this-&gt;call_back_1 = func1;
          $this-&gt;call_back_2 = func2;
     }


     function provokeCallBacks()
     {
          //this does not work, and gives an error  
          $this-&gt;call_back_1();


          //I would like to avoid this
          $method = $this-&gt;call_back_2;
          $method(); 
     }
}

$call1 = function(){ echo "inside call 1"};
$call2 = function(){ echo "inside call 2"};

$test = new foo(call1, call2);

$test-&gt;provokeCallBacks();
</code></pre>

<p><strong>* Update 1: Please ignore any syntax error as I have written this on the fly for demo puposes. *</strong></p>

<p>Inside foo:provokeCallBacks, I am trying to call the anonymous functions how ever the first way does not works and gives an error. The second one works but it's a bit stupid that I have to use a temp variable called "$method" to make the call. </p>

<p>I want to know if there exists a better way to call the anonymous function.</p>
