在PHP 5.3.0中,什么是函数“use”标识符? [英] In PHP 5.3.0, what is the function "use" identifier?
本文介绍了在PHP 5.3.0中,什么是函数“use”标识符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我查看了一些 PHP 5.3.0
功能,并在网站上看起来很有趣的一些代码上运行:
public function getTotal($ tax)
{
$ total = 0.00;
$ callback =
/ *这行:* /
function($ quantity,$ product)use($ tax,& $ total)
{
$ pricePerItem = constant(__ CLASS__。:: PRICE_。
strtoupper($ product));
$ total + =($ pricePerItem * $ quantity)*($ tax + 1.0);
};
array_walk($ this-> products,$ callback);
return round($ total,2);
}
作为匿名函数。
有人知道吗?任何文档?