views:

139

answers:

1

Hi,

I've got an object, which contains semicolons in the property names, when I var_dump, I get:

object(Sales) {

    [thisisa:propertyname] => 'some value'

}

So, how do I access the property? $object->thisisa:propertyname throws an error. I read somewhere a while ago you can wrap thisisa:propertyname in some characters (I've tried {, [, (, |) but I can't remember which.

Also, it seems that using:

$var = "thisisa:propertyname";
$object->$$var;

Doesn't work either.

Help!

Mike

+6  A: 

Try

echo $object->{'thisisa:propertyname'};

Also, For variable member variables, one $ is enough. So

$attr = "thisisa:propertyname";
echo $object->$attr;
gnud
Don’t forget the quotes: `$object->{'thisisa:propertyname'}` or `$object->{"thisisa:propertyname"}`.
Gumbo
Thanks - the one time I didn't run my example code :)
gnud