php - check if class name stored in a string is implementing an interface
I understand that my question is somehow wrong, but I'm still trying to solve this problem. I have an interface Programmer: interface Programmer { public function writeCode(); } and a couple of namespaced classes: Students\BjarneProgrammer (implements Programmer) Students\CharlieActor (implements Actor) I have this class names stored in array $students = array("BjarneProgrammer", "CharlieActor"); I want to write a function, that will return an instance of class if it's implementing Programmer interface. Examples: getStudentObject($students[0]); - It should return an instance of BjarneProgramme
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.