note 17879 deleted from function.get-parent-class by jimw

From: Date: Wed, 02 Jan 2002 12:03:44 +0000
Subject: note 17879 deleted from function.get-parent-class by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-24250@lists.php.net to get a copy of this message
Not only that, you can use it to determine an object's heritage by calling it repetedly. This comes in handy when you want to handle a group of objects that you expect to be derived from a common base class : // Returns true if $object is derived from $classname function is_type_of( &$object, $classname ) { if ( ! is_object( $object ) ) return false; $thisclass = get_class( $object ); while ( $thisclass ) { if ( ! strcasecmp( $thisclass, $classname ) ) return true; $thisclass = get_parent_class( $thisclass ); } return false; }

« previous php.notes (#24250) next »