Home  >  Article  >  php教程  >  php面向对象之Static关键字

php面向对象之Static关键字

WBOY
WBOYOriginal
2016-06-07 17:23:541113browse

        关于Static关键字在类中的使用,PHP手册给出了如下的约定:
   1、声明类成员或方法为static,就可以不实例化类而直接访问。不能通过一个对象来访问其中的静态成员(静态方法除外)。

   2、由于静态方法不需要通过对象即可调用,所以伪变量$this在静态方法中不可用。
   3、静态属性不可以由对象通过->操作符来访问。
   4、用::方式调用一个非静态方法会导致一个E

Statement:
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