Page 1 of 1

Check Class Inheritance

Posted: Tue Apr 01, 2008 10:27 pm
by aliasxneo
I have a function which I need to check if an object inherits a certain class and if so act on it. I'm not sure of PHP has a native function to check if the class extends another class and to get that class name which is why I'm asking here. If not can anyone suggest a way to determine if an object is extending a certain class? Thanks.

Re: Check Class Inheritance

Posted: Wed Apr 02, 2008 12:40 am
by Christopher
instanceof

Re: Check Class Inheritance

Posted: Wed Apr 02, 2008 12:51 am
by Chris Corbyn
Yep, as arborint suggests, in PHP5 you can use the "instanceof" operator, and in PHP4 you can use the is_a() function.