【发布时间】:2018-05-17 18:14:17
【问题描述】:
我想将一个函数发送到另一个函数中,以便稍后在该函数中执行。这个想法类似于jQuery中的回调成功函数。
想法是这样的:
function my_function($args)
{
// ...
// Code that creates the $result variable
// ..
// Execute the calback function, how??:
$args['callback_function']; // Handle the $result
}
$args = array(
'callback_function' => function($result)
{
// $result created in my_function()
}
);
my_function($args);
【问题讨论】:
标签: php function callback anonymous-function