Check Class Inheritance
Moderator: General Moderators
Check Class Inheritance
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.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Check Class Inheritance
Yep, as arborint suggests, in PHP5 you can use the "instanceof" operator, and in PHP4 you can use the is_a() function.