Function as properties and undefined method
<p>I am making a game, and came to the part to implement character abilities on the server-side.</p>

<p>So I have an array to hold all character abilities:</p>

<pre><code>$abils = array();
</code></pre>

<p>And a class for them:</p>

<pre><code>class Abil{
    private $timing;
    private $func;

    public function __construct($time, $func){
        global $abils;
        $this-&gt;timing = $time;
        $this-&gt;func = $func;
        array_push($abils,$this);
    }

    public function trigger($time,$params){
        if(preg_match('/^'.$this-&gt;timing.'$/',$time)) $this-&gt;func($params);
    }
}
</code></pre>

<p><code>$time</code> is the "timing" of the ability, as RegEx. For example, <code>\d\d-0</code> would be the start of anyone's turn.<br>
<code>$func</code> is a function to run when the ability is used.</p>

<p>When a certain "timing" is reached (for example, the start of someone's turn), a global <code>triggerAll()</code> function would be used to trigger all abilities of that timing:</p>

<pre><code>function triggerAll($time,$params = NULL){
    global $abils;
    foreach($abils as $abil) $abil-&gt;trigger($time,$params);
}
</code></pre>

<p>But then, when <code>triggerAll</code> is called, a fatal error is generated:<br>
<code>Fatal error: Call to undefined method Abil::func()</code></p>

<p>I suspect this is due to <code>$func</code> not being a METHOD but a PROPERTY which holds a function. Any workarounds?</p>
