note 101426 added to reflectionclass.getparentclass

From: Date: Thu, 16 Dec 2010 09:17:39 +0000
Subject: note 101426 added to reflectionclass.getparentclass
Groups: php.notes 
Request: Send a blank email to php-notes+get-174969@lists.php.net to get a copy of this message
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 ); } ---- Server IP: 195.26.5.11 Probable Submitter: 158.169.9.14 ---- Manual Page -- http://www.php.net/manual/en/reflectionclass.getparentclass.php Edit -- https://master.php.net/note/edit/101426 Del: integrated -- https://master.php.net/note/delete/101426/integrated Del: useless -- https://master.php.net/note/delete/101426/useless Del: bad code -- https://master.php.net/note/delete/101426/bad+code Del: spam -- https://master.php.net/note/delete/101426/spam Del: non-english -- https://master.php.net/note/delete/101426/non-english Del: in docs -- https://master.php.net/note/delete/101426/in+docs Del: other reasons-- https://master.php.net/note/delete/101426 Reject -- https://master.php.net/note/reject/101426 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174969) next »