title: Creating PHP class instance with a string
body: <p>I have two classes, <code>class ClassOne { }</code> and <code>class ClassTwo {}</code>. I am getting a string which can be either <code>"One"</code> or <code>"Two"</code>.</p>
  
  <p>Instead of using a long <code>switch</code> statement such as:</p>
  
  <pre><code>switch ($str) {
      case "One":
          return new ClassOne();
      case "Two":
          return new ClassTwo();
  }
  </code></pre>
  
  <p>Is there a way I can create an instance using a string, i.e. <code>new Class("Class" . $str);</code>?</p>