Jump to content

getting object's property by giving a string


gandalf0777

Recommended Posts

Hi,

 

I am wondering if it is a possibility to get an object property as in the following example:

 

$CFG->example_field = 'something';
$field = "example_field";

 

print $CFG->$field;

??? does not work of course

print $CFG[$field];

??? does not work of course

 

So I would like to have some kind of converting a string "example_field" to a name of the property of the $CFG object.

 

Anobody knows is this possible or not?

Regards,

Pawel

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.