Re: object reflection in php?
| From: | Michael Kimsal | Date: | Mon, 18 Mar 2002 15:52:12 +0000 |
| Subject: | Re: object reflection in php? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-88943@lists.php.net to get a copy of this message | ||
Erik Price wrote:
On Monday, March 18, 2002, at 06:28 AM, Filippo Veneri wrote:<snip> I think you missed his point. With your example, you still need to know the field name, which is what he's trying to avoid. Filippo, I think what you're looking for is: get_object_vars more info at http://www.php.net/manual/en/function.get-object-vars.php Does that help? Michael Kimsal http://www.phphelpdesk.com Taking the ? out of <?php support 734-480-9961Just to make myself understood: class obj { var $field; function obj( $value ) {Couldn't you just add another method called "return_field_name()" to the class? Then you could run this method from the script and you will be given the value of the field name. Your code would look like this:$this->field = $value;} } $o = new obj( "field value" ); How can i know, if possible, that the instance of obj pointed to by $o has a field named "field"? This would be useful to write an object to a database without knowing its structure 'a-priori'.