note 10549 added to method_exists

From: Date: Wed, 10 Jan 2001 04:52:18 +0000
Subject: note 10549 added to method_exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-9533@lists.php.net to get a copy of this message
this function tests the name of a member to see if that member is inherited... function is_parent_member ($name, $thisclass) { // this function makes alot of assumptions: // first: return array is a list not a set (i.e. is ordered) // second: parent_class exists // fourth: parent_class has a constructor // third: class has not overriden the name of the parent_class constructor $arr = get_class_methods(get_class($thisclass)); $arr2 = get_class_methods(get_parent_class($thisclass)); $started = false; $copy1 = array (); while (list($key, $val) = each ($arr)) { if ($started == false) { if ($val == get_parent_class($thisclass)) { $started = true; } } else { $copy1[] = $val; } } $copy2 = array(); $started = false; while (list($key, $val) = each ($arr2)) { if ($started == false) { if ($val == get_parent_class($thisclass)) { $started = true; } } else { $copy2[] = $val; } } foreach ($copy2 as $val2) { $found = false; foreach ($copy1 as $val1) { if ($val1 == $val2) { $found = true; } } if ($found == false) { if ($name == $val2) { return true; } } } return false; } http://www.php.net/manual/function.method-exists.php

« previous php.notes (#9533) next »