title: Limit scope of require'd class definitions to a function
body: <p>I have folder with many plugins. Each plugin contains same name class but different content:</p>
  <p><strong>plugin01.php</strong></p>
  <pre><code>class Plugin{
    public function get($a){
      return 'Plugin01 - '.$a;
    }
  }
  </code></pre>
  <p><strong>plugin02.php</strong></p>
  <pre><code>class Plugin{
    public function get($a){
      return 'Plugin02 - '.$a;
    }
  }
  </code></pre>
  <p>In Plugins.php, i want to load this plugins. But not only once.</p>
  <pre><code>class Plugins{
    public static function load($id){
      require $id.'.php';
      
      $plugin = new Plugin();
      return $plugin-&gt;get('test');
    }
  }
  
  echo Plugins::load('plugin01').&quot;\n&quot;;
  echo Plugins::load('plugin02').&quot;\n&quot;;
  echo Plugins::load('plugin01');
  </code></pre>
  <p>Expected result:</p>
  <blockquote>
  <p>Plugin01 - test</p>
  <p>Plugin02 - test</p>
  <p>Plugin01 - test</p>
  </blockquote>
  <p>Current Result:</p>
  <blockquote>
  <p>Fatal error: Cannot redeclare class Plugin</p>
  </blockquote>
  <p>This definitely does not work, because i am <code>redefining</code> class name and <code>including</code> more times same plugin.</p>
  <p>My question is, can I include file only in Function scope  (including all classes defined in external file), that if will not appear outside function?</p>
  <p>Can I do that with PHP, or must I use different names for each class?</p>