Looking at Wokman this framework, I found the following code http://doc3.workerman.net/worker-development/add.html
$task = new Worker();$task->onWorkerStart = function($task){ $to = 'workerman@workerman.net'; $content = 'hello workerman'; // 10秒后执行发送邮件任务,最后一个参数传递false,表示只运行一次 Timer::add(10, 'send_mail', array($to, $content), false);};
xxx=function(){}JS inside is common, but in PHP I was the first time to see, do not understand which, look at the guidance
Reply content:
Looking at Wokman this framework, I found the following code http://doc3.workerman.net/worker-development/add.html
$task = new Worker();$task->onWorkerStart = function($task){ $to = 'workerman@workerman.net'; $content = 'hello workerman'; // 10秒后执行发送邮件任务,最后一个参数传递false,表示只运行一次 Timer::add(10, 'send_mail', array($to, $content), false);};
xxx=function(){}JS inside is common, but in PHP I was the first time to see, do not understand which, look at the guidance
anonymous functions
The anonymous function (Anonymous functions), also called the closure function (closures), allows temporary creation of a function without a specified name. The value most often used as the callback function (callback) parameter. Of course, there are other applications as well.
http://www.php.net/manual/zh/functions.anonymous.php
Like JS, this is the use of the anonymous function of PHP.
The legendary anonymous function
Similar to python inside the LAMDA function