inheritance - How to check object instance is inherited from Abstract Class in PHP -


i have below abstract class

abstract class abstractperson{   ...... } 

i have inherited abstractperson account

class account extends abstractperson{   ...... } 

now going make object of class

$account= new account() 

i wondering how check $account object extended abstractperson class?

well, need reflection, , 2 methods getparentclass() & isabstract().

here's working example of need.

$accountreflection     = new reflectionclass('account'); $parentreflection     = new reflectionclass($accountreflection->getparentclass()->getname()); $isabstract           = $parentreflection->isabstract(); // return true of false 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -