title: instantiate a class from a variable in PHP?
body: <p>I know this question sounds rather vague so I will make it more clear with an example:</p>
  
  <pre><code>$var = 'bar';
  $bar = new {$var}Class('var for __construct()'); //$bar = new barClass('var for __construct()');
  </code></pre>
  
  <p>This is what I want to do. How would you do it? I could off course use eval() like this:</p>
  
  <pre><code>$var = 'bar';
  eval('$bar = new '.$var.'Class(\'var for __construct()\');');
  </code></pre>
  
  <p>But I'd rather stay away from eval(). Is there any way to do this without eval()?</p>