PHP xxx=function () {} What do you mean by this notation?

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

  • 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.