title: How to declare a class dynamically with a variable in php
body: <p>I am trying to make a small script that will load php files and then initiate classes automatically. I am trying to do it like this, </p>
  
  <pre><code>$className = ucfirst($folderName).'()';
  \Elementor\Plugin::instance()-&gt;widgets_manager-&gt;register_widget_type( new \Elementor\$className );
  //HERE I AM GETTING ERROR BECAUSE OF THE $class VARIABLE USED. 
  </code></pre>
  
  <p>The error I get: </p>
  
  <blockquote>
    <p>Parse error: syntax error, unexpected '$className' (T_VARIABLE), expecting identifier (T_STRING)</p>
  </blockquote>
  
  <p>How can I get ride of the error and initiate the class? </p>