How can I access an object property named as a variable in php?

前端 未结 5 1679
陌清茗
陌清茗 2020-12-04 16:04

A Google APIs encoded in JSON returned an object such as this

[updated] => stdClass Object
(
 [$t] => 2010-08-18T19:17:42.026Z
)

Anyone

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 16:48

    this works on php 5 and 7

    $props=get_object_vars($object);
    echo $props[$t];
    

提交回复
热议问题