问题
My object name is $distinct1
print_r($distinct1)
shows the object below but when I try to do
echo $distinct1->properties->city
OR
echo $distinct1->distinct_id
I don't get any value return. Any idea whats going on?
stdClass Object
(
[$distinct_id] => AAA
[$properties] => stdClass Object
(
[$city] => Palo Alto
[$country_code] => US
[$region] => California
[$name] => John Smith
)
)
回答1:
Hm, if your properties are really named like that:
$distinct1->{'$properties'}->{'$city'}
But if possible, I'd look into the mechanism that sets it like that & fix it there.
回答2:
The property names of that object actually start with $
for whatever weird reason.
echo $distinct1->{'$properties'}->{'$city'};
来源:https://stackoverflow.com/questions/15844824/trying-to-print-properties-of-stdclass-object-in-php-starting-with-literal