title: php - check if class name stored in a string is implementing an interface
body: <p>I understand that my question is somehow wrong, but I'm still trying to solve this problem.</p>
  
  <p>I have an interface <code>Programmer</code>:</p>
  
  <pre><code>interface Programmer {
      public function writeCode();
  }
  </code></pre>
  
  <p>and a couple of <strong>namespaced</strong> classes:</p>
  
  <ul>
  <li><code>Students\BjarneProgrammer</code> (implements <code>Programmer</code>)</li>
  <li><code>Students\CharlieActor</code> (implements <code>Actor</code>)</li>
  </ul>
  
  <p>I have this class names stored in array <code>$students = array("BjarneProgrammer", "CharlieActor");</code></p>
  
  <p>I want to write a function, that will return an instance of class if it's implementing <code>Programmer</code> interface.</p>
  
  <p><strong>Examples:</strong></p>
  
  <p><code>getStudentObject($students[0]);</code> - It should return an instance of <code>BjarneProgrammer</code> because it's implementing Programmer.</p>
  
  <p><code>getStudentObject($students[1]);</code> - It should return <code>false</code> because Charlie is not a Programmer.</p>
  
  <p>I tried it using <code>instanceof</code> operator, but the main problem is that I <strong>do not</strong> want to instantiate an object if it's not implementing Programmer.</p>
  
  <p>I checked <a href="https://stackoverflow.com/questions/9604090/how-to-load-php-code-dynamically-and-check-if-classes-implement-interface">How to load php code dynamically and check if classes implement interface</a>, but there is no appropriate answer as I don't want to create object unless it's returned by function.</p>