jordanwb Posted July 31, 2008 Share Posted July 31, 2008 How would I go about checking if a class extends or implements and class or interface? Link to comment https://forums.phpfreaks.com/topic/117637-solved-checking-if-a-class-implementsextends-another/ Share on other sites More sharing options...
DarkWater Posted July 31, 2008 Share Posted July 31, 2008 The instanceof operator works on parents and interfaces too. <?php class foo{ } class bar extends foo { } $bar = new bar; if ($bar instanceof foo) { echo "FOO!"; } else { echo "BAR!"; } ?> Echos "FOO!". Link to comment https://forums.phpfreaks.com/topic/117637-solved-checking-if-a-class-implementsextends-another/#findComment-605050 Share on other sites More sharing options...
jordanwb Posted July 31, 2008 Author Share Posted July 31, 2008 Thanks. Link to comment https://forums.phpfreaks.com/topic/117637-solved-checking-if-a-class-implementsextends-another/#findComment-605081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.