Re: [PHP4BETA] runtime class information

From: Date: Wed, 28 Jul 1999 19:04:55 +0000
Subject: Re: [PHP4BETA] runtime class information
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-2915@lists.php.net to get a copy of this message
This was a side-effect of implementation in PHP 3.0 and was never meant to work. We added three more functions to PHP 4.0 that allow you to get RTTI. get_class($obj) get_parent_class($obj) method_exists($obj,"method") You can use the last instead of isset(). Andi At 02:54 PM 7/28/99 +1000, Alan van den Bosch wrote:
How would I find if a member function exists in an instance of a class at runtime? In php3 I could use isset(), like this: function call_all($func,$arg){
        // $this->collection  is an array of objects of different types
        // $func is a function name
        // $arg is an argument to be passed to $func when called
        reset($this->collection);
        for ($i=0;$i<sizeof($this->collection);$i++){
                $cur=each($this->collection);
                $obj=$this->collection[$cur['key'];
                // only call the function if it is a member function
                // for the current object in the collection
                if (isset($obj->$func)){
                        $retval=$obj->$func($arg);
                }
        }
} This no longer works... are there any new statements/functions for dealling class runtime information ?? Alan -- PHP 4 Beta
--- Andi Gutmans <andi@zend.com> http://www.zend.com/

« previous php.version4 (#2915) next »