Dynamically add methods to an object
<p>I am, for fun, trying to make it able to give an array some options and then implode the array into a string which can be used with the WideImage class. But I am having troubles. It's like it's actually not possible.</p>

<p>My code is following:</p>

<pre><code>$options = array('resize'=&gt;'50,50');

$actions = implode('-&gt;', $options);
$img = WideImage::load($image) . $actions . ';';
</code></pre>

<p>This would make a string like: </p>

<pre><code>WideImage::load('../images/photo.jpg')-&gt;resize(50,50);
</code></pre>

<p>What I am searching for from you guys, is to tell me if this is possible at all.</p>

<p><strong>UPDATE</strong></p>

<p>When I am using eval() I am getting an error that the methods given to the wideimage class is undefined property.</p>

<p>Here is my code:</p>

<pre><code>$actions = 'resize(50,50)';
return eval('WideImage::load($image)-&gt;$actions-&gt;saveToFile('path/to/file')');
</code></pre>

<p>This gives me an error of undefined property, and says that saveToFile() is member of a non-object. But if I hardcode the resize and don't use $actions it's actually working. What am I doing wrong here?</p>
