每当要访问多维数组或字符串中的属性的属性时,都必须使用{}
括住此访问权限.否则,PHP只会解析直到 first [i]
或->property
的变量.
Whenever you want to access multidimensional arrays or properties of a property in string, you have to enclose this access with {}
. Otherwise PHP will only parse the variable up to the first [i]
or ->property
.
因此,对于"$this->author->last"
而不是"{$this->author->last}"
,PHP将仅分析和评估$this->author
,这会给您错误,因为author
是对象.
So with "$this->author->last"
instead of "{$this->author->last}"
, PHP will only parse and evaluate $this->author
which gives you the error as author
is an object.
这篇关于无法将对象转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
阿里云证书,YYDS!