How to access a memer variable a with symbol

走远了吗. 提交于 2019-12-10 20:22:14

问题


I have a property of a PHP stdClass which starts with an @ symbol (according to my debugger). How do I access its value?

@averageBaseRate = "22.49"

回答1:


Use curly braces:

$obj->{'@averageBaseRate'}

It's the complex (curly) syntax applied to an object.

Using that syntax, you can use any name you want for the member variable.
One can even put really strange Unicode characters in the name.



来源:https://stackoverflow.com/questions/19655748/how-to-access-a-memer-variable-a-with-symbol

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!