Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand Anonymous function and callback function in php

Shulou Source: shulou.com Published: 2022-06-03 05:11:42 10月21日 Update

This article shows you how to understand anonymous functions and callback functions in php. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

An anonymous function is a function that has no name and can be assigned to a variable and then called for use.

A callback function is a function that is used by another function as a parameter value.

The code example is as follows:

/ / anonymous function $a=function () {echo "www.php.cn";} $a (); / / callback function name as an argument for other functions to use call_user_func ("function name", argument) function $a () {echo "www.php.cn" } call_user_func ("a", parameter) / / also means that you can pass in an anonymous function to use the above is how to understand anonymous functions and callback functions in php. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Functions parameters content names skills knowledge conciseness brevity code variables masterpieces that is articles more examples articles industries information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS NVidia vpn Xiaomi MariaDB