PHP best method to affect variables in a function
<p>I'm playing around with hooking into functions, the hook will call the method of another object, what is the best way of changing the value $price in the parent function before it is returned?</p>

<pre><code>function _product_price ($price,$taxable = true)
{
    $shop-&gt;_hook('PRODUCT_PRICE_BEFORE');
    $price = 100.00;
    $shop-&gt;_hook('PRODUCT_PRICE_AFTER');
    return number_format($price,2);
}
</code></pre>

<p>Thanks guys, would this be a suitable solution?</p>

<pre><code>function _product_price ($price,$taxable = true)
{
    global $shop;
    $shop-&gt;_hook('PRODUCT_PRICE_BEFORE');
    $price = 100.00;
    $shop-&gt;passedArgs['price'] = $price;
    $shop-&gt;_hook('PRODUCT_PRICE_AFTER');
    return number_format($shop-&gt;passedArgs['price'],2);
}
function _hook ()
{
    global $shop;
    $shop-&gt;passedArgs['price'] = 23.00;
    return;
}
</code></pre>
