title: Setting a Variable as a Class in PHP
body: <p>Want to know if I can dynamically create a PHP class by stating it as a variable.</p>
  
  <p>i.e.</p>
  
  <pre><code>class $vaiable {
  
    public $foo2,
           $foo3,
           $foo4;
  
  
    function __construct(array $data = null) {
      if( empty($data) ) 
        return;
  
      foreach( $data as $field =&gt; $value ) {
        $this-&gt;$field = $value;
      }
    }
  
  }
  </code></pre>