note 52578 deleted from function.get-class by nlopess

From: Date: Fri, 06 May 2005 18:50:07 +0000
Subject: note 52578 deleted from function.get-class by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-89023@lists.php.net to get a copy of this message
Note Submitter: sinasalek at hotpop dot com ---- /** * get name of object by its value, if its name does unique * * @param object $object * @return string */ function get_instance_name($object) { $instance = md5(serialize($object)); foreach( $GLOBALS as $variable => $value ) if( md5(serialize($value)) == $instance ) return $variable; } //--(End)-->example class Foo { public function get_name() { return get_instance_name($this); } } $foo = new Foo; echo $foo->get_name(); //--(End)-->example

« previous php.notes (#89023) next »