静态方法this_静态方法和$ this

静态方法this

静态方法this

The book tells about static methods but it forgets to mention that you cannot use $this in static methods. A static method is pretty much like a normal stand-alone function is not aware about the object as a whole. So you can call the static method when no object of that class exists. In this case the method would have no idea what $this is.

该书介绍了静态方法,但忘记了您不能在静态方法中使用$ this。 静态方法很像普通的独立函数不了解整个对象。 因此,当该类的对象不存在时,您可以调用静态方法。 在这种情况下,该方法将不知道$ this是什么。

Tell your friends about this post on Facebook and Twitter

FacebookTwitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/static-methods-and-this/

静态方法this

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值