Answer the question
In order to leave comments, you need to log in
How to execute a custom function from the function itself?
How to call a function in PHP header and pass parameters to it?
For example:myFunc('helloworld',function(){ echo "test" });
Answer the question
In order to leave comments, you need to log in
We check whether the variable is a value or a function, if it is a function, then we call it
myFunc('helloworld', function(){
echo "test"
});
function myFunc($key, $object){
return is_callable($object) ? call_user_func($object):$object;
}
For example like this:
function myFunc($text, $func)
{
$func($text);
}
myFunc("blabla", function($param) { echo $param;});
$hello = function($name = '') {
return "Hello $name";
};
echo $hello('John'); // Hello John
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question