note 58060 deleted from function.class-parents by helly

From: Date: Tue, 01 Nov 2005 21:50:35 +0000
Subject: note 58060 deleted from function.class-parents by helly
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-97949@lists.php.net to get a copy of this message
Note Submitter: TJ <php dot net at tjworld dot net> ---- When a class has no parent class this function returns its own class name as parent, rather than an empty array as you might expect. So a super-class and it's first sub-class will both see the same result from a call to class_parents($this); This means finding out whether a class is the top-most super-class in an inheritence chain requires more work to determine if it is the root of a heirachy. $parents = class_parents($this); if(count($parents==1) && $parents[get_class()] == get_class()) { echo 'This is a base class.'; } else echo 'This is a sub-class.';

« previous php.notes (#97949) next »