更新时间:2023-11-29 23:42:46
将其封装为单引号字符串:
Encapsulate it as a single-quoted string:
echo $object->id->{'$t'};
请注意,出于与不能使用$object->id->$t
相同的原因,不能使用双引号:PHP将尝试对$t
进行插值.但是,如果您逃脱了美元符号,则可以使用双引号:
Note that you cannot use double quotes for the same reason you cannot use $object->id->$t
: PHP will attempt to interpolate $t
. However, you could use double quotes if you escape the dollar sign:
echo $obj->id->{"\$t"};
您可以在这个简单的演示中看到它的运行情况.
You can see it working in this simple demo.