I am the Fire Phoenix of Special Forces Episode Episode Introduction to PHP Function Syntax 1

WBOY
Release: 2016-07-29 08:40:05
Original
1612 people have browsed it

Copy code The code is as follows:


function getAdder($x)
{
return function ($y) use ($x) {
return $x + $y;
};
}
$adder = getAdder(8);
echo $adder(2); // prints "10"


Here, getAdder() function creates a closure using parameter $× (keyword "use" forces getting variable context) , which takes additional arguments $Y and returns to the call. This function can be stored as a parameter to another function, etc. See the Lambda Functions and Closure RFC for details.

The above has introduced the introduction to the PHP function syntax of I Am the Special Forces Fire Phoenix Episode One, including the introduction to the plot episodes of I Am the Fire Phoenix Special Forces. I hope it will be helpful to friends who are interested in PHP tutorials.

source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!