You are here: Re: preg_replace_callback, class method? « PHP Programming Language « IT news, forums, messages
Re: preg_replace_callback, class method?

Posted by Colin Fine on 10/09/06 22:14

Kimmo Laine wrote:
> I tried to use a class member function as a callback in
> preg_replace_callback, but failed. It announces: " Warning:
> preg_replace_callback() [function.preg-replace-callback]: requires argument
> 2, 'myclass::myfunction', to be a valid callback in ..."
>
> I tried both myclass::myfunction and $this->myfunction, neither worked. Is
> there really no way of using a class member as a callback, it has to be an
> external function? That sucks... :(
>
>
>
From
http://uk.php.net/manual/en/language.pseudo-types.php#language.types.callback:

"Some functions like call_user_func() or usort() accept user defined
callback functions as a parameter. Callback functions can not only be
simple functions but also object methods including static class methods.

"A method of an instantiated object is passed as an array containing
an object as the element with index 0 and a method name as the element
with index 1.

"Static class methods can also be passed without instantiating an object
of that class by passing the class name instead of an object as the
element with index 0. "

Colin

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация