Looking at the time frame of the wokmanarchitecture, we found the following code doc3.workerman.networker-developmentadd.html {code ...} xxxfunction () {} is common in JS, but in php I still see for the first time, do not understand it, hope to look at the wokman framework, 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 '; // execute the mail sending Task 10 seconds later. If the last parameter is set to false, Timer: add (10, 'Send _ mail', array ($, $ content), false );};
xxx=function(){}It is common in JS, but I am still seeing it for the first time in PHP. I don't understand it. I hope you can give me some advice.
Reply content:
Looking at the wokman framework, we 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 '; // execute the mail sending Task 10 seconds later. If the last parameter is set to false, Timer: add (10, 'Send _ mail', array ($, $ content), false );};
xxx=function(){}It is common in JS, but I am still seeing it for the first time in PHP. I don't understand it. I hope you can give me some advice.
Anonymous Functions
An Anonymous function (Anonymous functions), also called a closure function (closures), allows you to temporarily create a function without a specified name. The value that is most often used as the callback function parameter. Of course, there are other applications.
Http://www.php.net/manual/zh/functions.anonymous.php
Similar to Js, this is the use of PHP anonymous functions.
The legendary anonymous Function
Similar to the lamda function in python