这是我的JSON对象PHP访问json_decode数据
object(stdClass)#23 (2) { ["type"]=> string(4) "text" ["$t"]=> string(10) "cippalippa" }
我如何可以访问"text" ["$t"]
?
这是我的JSON对象PHP访问json_decode数据
object(stdClass)#23 (2) { ["type"]=> string(4) "text" ["$t"]=> string(10) "cippalippa" }
我如何可以访问"text" ["$t"]
?
解决了这个字符串: $ OBJ - > { '$ T'}
你需要躲避美元符号:
echo $object["\$t"];
$object = json_decode({ ["type"]=> string(4) "text" ["$t"]=> string(10) "cippalippa" });
echo $objetct->$t;
这方面的工作?
您需要使用这个语法:
$object->{'$t'}
在这里提到的不作为的工作,另外两个:
- 一个目的是不是一个数组$object["\$t"]
- 这将被解释为variable variable:$objetct->$t
[...]如果你有这样的表达式
$foo->$bar
,那么本地范围将检查$bar
,其价值将被用作$foo
的财产的名称。
你想要访问什么? ''text''或'[$ t]' – cspray 2012-02-08 11:41:58