title: Use keyword in functions - PHP
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1065188/in-php-5-3-0-what-is-the-function-use-identifier-should-a-sane-programmer-use">In Php 5.3.0 what is the Function &ldquo;Use&rdquo; Identifier ? Should a sane programmer use it?</a>  </p>
  </blockquote>
  
  
  
  <p>I've been examining the Closures in PHP and this is what took my attention:</p>
  
  <pre><code>public function getTotal($tax)
      {
          $total = 0.00;
  
          $callback =
              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>And somebody please give me an explanation about the usage of <code>use</code> in this code.</p>
  
  <pre><code>function ($quantity, $product) use ($tax, &amp;$total)
  </code></pre>
  
  <p>When I search <code>use</code> in PHP, it finds <code>use</code> keyword where it is used in namespaces but here it looks different.</p>
  
  <p>Thanks.</p>