How to add a new method to a php object on the fly?
- by MadBad
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->doSomething();
//Fatal error: Call to undefined method stdClass::doSomething()