title: Why does PHP compact() use strings instead of actual variables?
body: <p>Can anyone explain the benefit of PHP's <a href="http://php.net/manual/en/function.compact.php">compact()</a> function accepting the string of 'a variable with that name' instead of the actual variable?</p>
  
  <p>For example:</p>
  
  <pre><code>$foo = 'foo';
  $bar = 'bar';
  
  $compacted = compact('foo', 'bar');
  </code></pre>
  
  <p>Why do I need to pass a string of the variable name instead of just passing the variable itself and PHP handling mapping this to an array? Like so:</p>
  
  <pre><code>$compacted = compact($foo, $bar);
  </code></pre>