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

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

问题描述

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

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

但是返回的值是0,为什么?以及如何将其检索为 1?

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

谢谢

推荐答案

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

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

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