Re: callback function in class
| From: | John W. Holmes | Date: | Sat, 09 Aug 2003 01:42:19 +0000 |
| Subject: | Re: callback function in class | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158970@lists.php.net to get a copy of this message | ||
Evan Nemerson wrote:
Basic problem: I need to use preg_replace_callback, and would like the callback parameter to be a function in a class (the same as that which contains the call to preg_replace_callback). "classname::function" doesn't seem to work... Anyone have any ideas?Besides create_function(), the very first comment on the preg_replace_callback() page says: --- Also, if you want to use a *static* class method for the callback function, you can refer to it like this: preg_replace_callback(pattern, array('ClassName', 'methodName'), subject) In PHP5, from within the class: preg_replace_callback(pattern, array('self', 'methodName'), subject) --- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ PHP|Architect: A magazine for PHP Professionals – www.phparch.com