Was ist ein Abschluss in PHP und warum wird der Bezeichner "use" verwendet?

Ich überprüfe einigePHP 5.3.0 Features und lief über einige Code auf der Website, die ziemlich lustig aussieht:

public function getTotal($tax)
{
    $total = 0.00;

    $callback =
        /* This line here: */
        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);
}

als eines der Beispiele aufanonyme Funktionen.

Weiß jemand davon? Beliebige Unterlagen? Und es sieht böse aus, sollte es jemals benutzt werden?

Antworten auf die Frage(5)

Ihre Antwort auf die Frage