note 101426 deleted from reflectionclass.getparentclass by danbrown

From: Date: Thu, 16 Dec 2010 11:13:54 +0000
Subject: note 101426 deleted from reflectionclass.getparentclass by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174975@lists.php.net to get a copy of this message
Note Submitter: havelangep at hotmail dot com ---- A quick note about message from jochem at drecomm dot nl. Your code ends up in an infinite loop. Here is a quick fix: function IsOrExtends( $search, $className ) { $class = new ReflectionClass( $className ); $names = array(); $names[] = $class->getName(); while( false !== ($parent = $class->getParentClass() )) { $names[] = $parent->getName(); $class = $parent; // This avoids the loop } return in_array( $search, $names ); }

« previous php.notes (#174975) next »