PHP: Callbacks in OOP

Note to the future myself:

Callbacks to object methods in PHP are made by:

call_user_func(array($object_reference, 'method_name'));

Examples:

call_user_func(array($this, 'doSomething'));  // in the current object's scope
call_user_func(array('MyClass', 'doSomething'));  // anywhere
call_user_func('MyClass::doSomething');  // As of PHP 5.2.3

No related posts.

Tags:

Leave a Reply

You must be logged in to post a comment.