Home > php教程 > php手册 > PHP 函数语法介绍一

PHP 函数语法介绍一

WBOY
Release: 2016-06-13 12:23:23
Original
744 people have browsed it

复制代码 代码如下:


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


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