Home > Backend Development > PHP Tutorial > Detailed explanation of anonymous functions and callback functions in php

Detailed explanation of anonymous functions and callback functions in php

王林
Release: 2023-04-08 08:20:01
forward
2853 people have browsed it

Detailed explanation of anonymous functions and callback functions in php

Anonymous function is a function without a name. You can assign the function to a variable and then call it.

The callback function refers to a function that is used as a parameter value for another function.

(Free learning video tutorial sharing: php video tutorial)

Code examples are as follows:

//匿名函数 没名称的函数
$a=function (){
echo "m.sbmmt.com";
}
$a();
//回调函数 函数名作为参数供其他函数使用
call_user_func("函数名",参数)
function $a(){
echo "m.sbmmt.com";
}
call_user_func("a",参数)
//也相当于可以传入一个匿名函数进去使用
Copy after login

Recommended related article tutorials: php tutorial

The above is the detailed content of Detailed explanation of anonymous functions and callback functions in php. For more information, please follow other related articles on the PHP Chinese website!

source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template