function ($quantity, $product) use ($tax, &$total)
{
$pricePerItem = constant(__CLASS__ . "::PRICE_" .
strtoupper($product));
$total += ($pricePerItem * $quantity) * ($tax + 1.0);
};
变量有作用范围,use 的作用是将上一级作用范围中的变量导入进匿名函数中,使其在匿名函数中可用,但不是参数。