How to pass function as param to a class's local var
<p>How to pass function to a class as param then assign it to local class's var!</p>

<p>This is my scenario, can this be solved?</p>

<pre class="lang-php prettyprint-override"><code>&lt;?php
class a {
  protected $var;

  function __construct($fun) {
    echo $fun('world'); // This is working perfect
    $this-&gt;var = $fun;
  }

  function checkit($x) {
    return $this-&gt;var($x);  // This is not working [ Call to undefined method a::var() ]
  }
}
$mth = 'mathm';
$cls = new a(&amp;$mth);    // result [ hello (world) ]

echo $cls-&gt;checkit('universe');  // &lt;- not working as it fail

function mathm($i) {
  return 'hello (' . $i . ')';
}
?&gt;
</code></pre>
