What does PHPxxx = function () {} mean?

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.