我是一个初学者,在理解php中的->语法时遇到麻烦,我知道它用于访问类中的对象,但是如果我输入多个->是什么意思,例如:
$this -> $var1 -> var2 -> var3
It's the same as accessing nested arrays using this:
$arr['key1']['key2']['key3']
(I hope this analogy is helpful to you.)
$this->var1->var2->var3
Here $this
is an object which has a property var1
. var1
is also an object itself which has a property var2
. var2
is also an object itself which has a property var3
. It could be constructed as such:
$this->var1 = new stdClass;
$this->var1->var2 = new stdClass;
$this->var1->var2->var3 = new stdClass;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.