title: In PHP, what is a closure and why does it use the "use" identifier?
body: <p>I'm checking out some <code>PHP 5.3.0</code> features and ran across some code on the site that looks quite funny:</p>
  
  <pre><code>public function getTotal($tax)
  {
      $total = 0.00;
  
      $callback =
          /* This line here: */
          function ($quantity, $product) use ($tax, &amp;$total)
          {
              $pricePerItem = constant(__CLASS__ . "::PRICE_" .
                  strtoupper($product));
              $total += ($pricePerItem * $quantity) * ($tax + 1.0);
          };
  
      array_walk($this-&gt;products, $callback);
      return round($total, 2);
  }
  </code></pre>
  
  <p>as one of the examples on <a href="http://www.php.net/manual/en/functions.anonymous.php" rel="noreferrer">anonymous functions</a>.</p>
  
  <p>Does anybody know about this? Any documentation? And it looks evil, should it ever be used?</p>