note 88664 modified in function.is-callable by danbrown

From: Date: Mon, 02 Feb 2009 20:13:46 +0000
Subject: note 88664 modified in function.is-callable by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-150125@lists.php.net to get a copy of this message
<?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; } ?> --was-- /** * 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; } http://php.net/manual/en/function.is-callable.php

« previous php.notes (#150125) next »