title: dynamic class names in php
body: <p>I have a base class called <code>field</code> and classes that extend this class such as <code>text</code>, <code>select</code>, <code>radio</code>, <code>checkbox</code>, <code>date</code>, <code>time</code>, <code>number</code>, etc.</p>
  
  <p>Classes that extend <code>field</code> class are dynamically called in a directory recursively using <code>include_once()</code>. I do this so that I ( and others) can easily add a new field type only by adding a single file</p>
  
  <p>What I want to know: Is there a way to substantiate a new object from one of these dynamically included extending classes from a variable name?</p>
  
  <p>e.g. a class with the name <code>checkbox</code> :</p>
  
  <pre><code>$field_type = 'checkbox';
  
  $field = new {$field_type}();
  </code></pre>
  
  <p>Maybe this would work? but it does not?</p>
  
  <pre><code>$field_type = 'checkbox';
  
  $field = new $$field_type();
  </code></pre>