Voting

: max(five, one)?
(Example: nine)

The Note You're Voting On

edgar at goodforall dot eu
15 years ago
Just a little toy I thought up, I would like to share. Creates an anonymous function, which let you use a class as a function.

In php 5.3 there is support for real functors (trough __invoke):

<?php
function createFunctor($className){
$content = "
static \$class;
if(!\$class){
\$class = new
$className;
}
return \$class->run(\$args);
"
;
$f = create_function('$args', $content);
return
$f;

}
class
test {
public function
run($args){
print
$args;
}
}
$test = createFunctor('test');
$test('hello world');
?>

<< Back to user notes page

To Top