note 88664 deleted from function.is-callable by danbrown

From: Date: Sun, 22 Feb 2009 00:39:47 +0000
Subject: note 88664 deleted from function.is-callable by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-150946@lists.php.net to get a copy of this message
Note Submitter: JuanD ---- <?php /** * The is_callable php function only considers methods declared in the class itself, and ignores the parent's. * This version considers all of the hierarchy. * * @param (string|Object) $class_name * @param string $method_name */ function isCallable( $class_name, $method_name ){ // Check class itself if( is_callable( array( $parent_class, $method_name ) ) ){ return true; } // Check all parents while( $parent_class = get_parent_class( $class_name ) ){ if( is_callable( array( $parent_class, $method_name ) ) ){ return true; } $class_name = $parent_class; } return false; } ?>

« previous php.notes (#150946) next »