Home > Backend Development > PHP Tutorial > 类成员修饰符的疑义

类成员修饰符的疑义

WBOY
Release: 2016-06-13 11:52:49
Original
985 people have browsed it

类成员修饰符的疑问

class a{<br />    private static $p1;<br />    public static $p2;<br />}
Copy after login

如上代码,成员变量前面加private static修饰符和只用private区别在哪呢?同理,public static和public区别又在哪呢?

------解决方案--------------------
Static关键字:声明类成员或方法为static,就可以不实例化类而直接访问。不能通过一个对象来访问其中的静态成员(静态方法除外)
------解决方案--------------------
private 私有的,只在声明的类中可以访问
public 共有的,可以被任何人访问(默认)
static 静态的,只能用静态方式访问 classname::Identifiers
------解决方案--------------------
静态方法或者属性,外部可以调用,
private定义,只能在类的内部调用

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template