按字符串访问对象属性的正确名称是什么


What is the proper name for accessing an object property by string?

我已经搜索了一段时间,找不到这种方法的实际名称

在 PHP 示例中:

$var->{'property_name'}

根据您正在访问的内容,它将被称为...

  • 一个variable variable
  • 一个variable property
  • 一个variable function

值得注意的是,只有在需要消除表达式歧义时才需要大括号(请记住,您使用的字符串本身可能存储在变量中!

等等。这记录在变量的 PHP 手册中。