使用字符串+变量获取对象变量 [英] Getting object variable using string + variable

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

问题描述

我想做这样的事情: echo $myObject->value_$id,但是我不知道正确的语法,而且不确定是否可以.

I would like to do something like this: echo $myObject->value_$id but I don't know proper syntax and I'm not sure if it is possible.

$id是一些PHP变量,例如具有值1.最后,我想获取$myObject->value_1,但是数字部分(1)应该是动态的.

$id is some PHP variable, for example has value 1. In the end, I would like to get $myObject->value_1 but the number part (1) should be dynamic.

推荐答案

该功能称为

这篇关于使用字符串+变量获取对象变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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