Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
191 views
in Technique[技术] by (71.8m points)

怎么理解php里面的$this

  1. 从打印的角度讲,$this和类的实例对象一模一样
  2. 从可以访问的属性来说,$this可以访问非静态属性,类的实例对象只能访问public属性

怎么理解$this和类的实例对象之间的关系?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  1. “实例对象”应该是“对象实例”
  2. “对象实例”相当于别人眼中的你,可以看到你的样子你的穿着(public),但是不清楚你的内心(prviate
  3. $this 相当于你自己,可以扪心自问(private

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...