You are here: Re: Defining a callback Func for preg_replace_callback(), within some class's method « PHP Programming Language « IT news, forums, messages
Re: Defining a callback Func for preg_replace_callback(), within some class's method

Posted by Chung Leong on 09/27/96 11:37

jody.florian@gmail.com wrote:
>
> They're not implementing a callback function with create_function() in
> a class context, as opposed to my example above.
>
> Since it's a) not wise and b) not possible to declare a function within
> a method (since it would be re-declared each time the method's used)
> I'm still quite at a loss myself
>
> I'm hazy on my lambda calculus but surely there's a way round this,
> other than creating a method solely as a one-off callback?

Given it a rest. Like I said, PHP does not have built-in support for
closure. It's possible to implement a closure class, of course. But
then you end up with an additional class floating around instead of a
method.

If you hate having an extra method that much, just have the method call
itself and branch based on the parameter passed. Example:

function output($param = null){
if($param) {
}
else {
$outputString = preg_replace_callback( ... array($this,
'output') ... );
}
}

 

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

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