连字符对象键 [英] Hyphens in Keys of Object

查看:75
本文介绍了连字符对象键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个stdClass的对象是这样的:

  stdClass的对象([KEY-西] => 1 [迪斯尼土地] => 1)

我想找回这样的值:

$ objectName->关键西部

但返回的值是0,为什么呢?我怎样才能找回它为1?

感谢


解决方案

 回声$ objectName-> {'关键西部'};

I have an stdClass Object like this:

stdClass Object ( [key-west] => 1 [disney-land] => 1 ) 

I am trying to retrieve the value like this:

$objectName->key-west

but the value returned is 0. Why? and How can I retrieve it as 1?

Thanks

解决方案

echo $objectName->{'key-west'};

这篇关于连字符对象键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆