
概述
正在学习设计模式,之前有一篇文章关于单例模式的文章,重新读了这篇文章,发现对static关键字掌握不是很牢靠,重新温习一下。
static关键字
PHP手册里对static关键字的介绍如下:
Declaring class properties or methods as static makes them accessible without needing an instantiation of the class. A property declared as static cannot be accessed with an instantiated class object (though a static method can).
大体意思是,将类的属性和方法声明为静态以后,可以直接访问静态属性和方法,而不需要实例化对象。
PHP中静态成员和方法的特性如下:
1.静态成员不能通过类的实例访问,但是静态方法可以。
2.静态成员不能通过-
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...