title: Dynamically creating classes
body: <p>I have been using active record for quite a while, and I wanted a little change of scenery, some developer friends suggested looking into ORM, all of the ORM projects I have looked at require a separate class extending the ORM class.</p>
  
  <p>My question is: is there any way to dynamically create a class using PHP from within a function <strong>without</strong> <code>eval</code>?</p>
  
  <p>This is what I have:</p>
  
  <pre><code>&lt;?php
      class Constructor
      {
              function new_class($class)
              {
                      $myself = get_called_class();
                      eval("class {$class} extends {$myself} { }");
              }
              function say_hi()
              {
                      $class = get_called_class();
                      echo "Hi, {$class}!";
              }
      }
  
      $constructor = new Constructor;
      $constructor-&gt;new_class("Greeter");
  
      $greeter = new Greeter;
  
      $greeter-&gt;say_hi(); // Hi, Greeter!
  </code></pre>
  
  <p>But, my client informs me that <code>eval</code> is blocked on his environment due to him being on shared hosting.</p>