如何"动态"向对象添加新方法?
$me= new stdClass; $me->doSomething=function () { echo 'I\'ve done something'; }; $me->doSomething(); //Fatal error: Call to undefined method stdClass::doSomething()
php methods
methods ×1
php ×1