PHP function name parameters and closures

Source: Internet
Author: User
PHP function name parameter arrayarray_filter (array $ input [, callable $ callback]) some functions such as call_user_func () or usort () can accept custom callback functions as parameters. Callback functions can not only be simple functions, but also object methods, including static class methods. An instantiated

PHP function name parameter array array_filter (array $ input [, callable $ callback = ""]) some functions such as call_user_func () or usort () user-defined callback functions can be used as parameters. Callback functions can not only be simple functions, but also object methods, including static class methods. An instantiated

PHP function name Parameters
array array_filter ( array $input [, callable $callback = "" ] )

Some functions, suchcall_user_func()Orusort()User-defined callback functions can be used as parameters. Callback functions can be moreSimple FunctionsCan also be an object method, includingStatic Class Method.
The method of an instantiated object is passed as an array. subscript 0 contains the object, and subscript 1 contains the method name.

Static class methods can also be passed without instantiating the class object, as long as the subscript 0 contains the class name rather than the object. From PHP 5.2.3, you can also pass 'classname: methodname '.

Except for common user-defined functions,create_function()It can be used to create an anonymous callback function. Closure can also be passed to the callback parameter since PHP 5.3.0.

 

Closure

 

Original article address: PHP function name parameters and closures. Thank you for sharing them with me.

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.