Home >Backend Development >PHP Tutorial >PHP 函数语法介绍一_php技巧

PHP 函数语法介绍一_php技巧

WBOY
WBOYOriginal
2016-05-17 09:32:06947browse
复制代码 代码如下:

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

在这里, getAdder ( )函数创建一个封闭使用参数$ × (关键字“使用”势力越来越变量上下文) ,它需要额外的参数$ Y和返回到调用。这种功能可以储存,因为作为参数到另一个功能等详细内容见兰布达职能和关闭的RFC 。
Statement:
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