如何通过PHP从这个对象中检索属性?

时间:2015-06-25 10:33:03

标签: php oop object

我有一个从Expedia API响应的对象。

[Surcharges] => stdClass Object
(
    [@size] => 1
    [Surcharge] => stdClass Object
        (
            [@type] => TaxAndServiceFee
            [@amount] => 9.59
        )

)

如何检索@typevà@ amount属性。

我尝试了宽度Surcharges->Surcharge->typeSurcharges->Surcharge->@type,但没有成功

2 个答案:

答案 0 :(得分:2)

尝试使用

Surcharges->Surcharge->{"@type"}

答案 1 :(得分:1)

尝试

Surcharges->Surcharge->{"@type"}