Re: OOP class names

From: Date: Tue, 01 Oct 2002 16:37:33 +0000
Subject: Re: OOP class names
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-118389@lists.php.net to get a copy of this message
From what you say you dont want get_class_name because this gives you the name of the class not the instance of it - which is really no different from asking how to get the name of any var. I dont really know why you would want to do this unless you are dynamically naming the objects. There is get_defined_vars but this gives you everything, environment vars etc and u would have to go through the lot. I am assuming you have the objects in some sort of container - because if you dont know their names that is the only way you can access them - so the only way I can think of is how you name them in the first place. eg. use the name as the key in the container $arr = array(); for ($i = 0; $i < 10; $i++) { $name = "classname$i"; $$name = new blah(); $arr[$name] = $$name; } Maybe there's another way but I cant think of one. Debbie ----- Original Message ----- From: "Davíð Örn Jóhannsson" <david@atom.is> To: <php-general@lists.php.net> Sent: Tuesday, October 01, 2002 1:59 PM Subject: [PHP] OOP class names > Is there any way to get a print out of class names of an object, lets > say I have a object called obj and I have x number of classes and I want > to find out, theyr names, for example obj->class1 obj->class2 etc. > > Thanks David >

« previous php.general (#118389) next »