How do I add a new method to an object \"on the fly\"?
$me= new stdClass; $me->doSomething=function () { echo \'I\\\'ve done something\'; }; $me->
To see how to do this with eval, you can take a look at my PHP micro-framework, Halcyon, which is available on github. It's small enough that you should be able to figure it out without any problems - concentrate on the HalcyonClassMunger class.