我的呼叫得到回复:print_r($response)
GetItemResponseType Object
(
[Item:protected] => ItemType Object
(
[ApplicationData:protected] => 651034.9.3011
[BuyerProtection:protected] => ItemEligible
[BuyItNowPrice:protected] => AmountType Object
(
[attributeValues] => Array
(
[currencyID] => EUR
)
[value:protected] => 0.0
)
[Country:protected] => DE
)
)
我读过这篇文章(如何在PHP中获得对象的受保护属性),但我无法重现该解决方案。
我如何获得国家的价值,即:
function accessProtected($obj, $prop) {
$reflection = new ReflectionClass($obj);
$property = $reflection->getProperty($prop);
$property->setAccessible(true);
return $property->getValue($obj);
}
如果我打电话给,我什么也得不到
echo accessProtected($response, 'Country');
问候,Matthias
您应该在类中创建公共或静态的getter和setter函数。
我的问题的答案是:
echo $response->Item->Country;
谢谢。