|
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]
|