Home  >  Article  >  Backend Development  >  What are the keywords in php

What are the keywords in php

王林
王林Original
2019-10-10 17:51:445145browse

What are the keywords in php

Any PHP developer needs to master 6 keywords when using object-oriented to build WEB applications, they are:

Private

Private is the core part of access control. Therefore, properties (variables) or methods defined as Private in a class can only be accessed within the class, and any instance (object) or subclass of the class Classes cannot be accessed, and similarly, you cannot access directly through the class name.

Protected

Protected’s access level is second only to Private. Properties (variables) or methods defined as Protected can not only be accessed in this class, but also in this class. It can also be accessed in subclasses of the class, which is not possible with Private attributes.

Public

Public has the greatest access rights. Properties (variables) or methods defined as Public can be accessed anywhere in the program and at any time.

static

When we declare an attribute (variable) in a class as static, then the value of the attribute is visible in all its objects and is a Shared variables, therefore, static attribute values ​​depend on the class rather than the object. Static properties cannot be accessed through objects, but can be accessed directly using the class name plus the :: symbol. Similarly, static methods also have object sharing characteristics, but you need to pay attention to the following two points:

1. Access static methods directly through the class name plus::

2. $this cannot be used in static methods Keyword

Final

If an attribute (variable) is modified by Final, then the attribute (variable) value cannot be changed. If it is a function, the function cannot be modified. Overwrite or overwrite.

Abstract

Classes defined as Abstract cannot be instantiated. Any class, if at least one method in it is declared as Abstract, then this class must be declared as Abstract. A method defined as Abstract only declares its calling method (parameters) and cannot define its specific function implementation.

Recommended tutorial: PHP video tutorial

The above is the detailed content of What are the keywords in php. For more information, please follow other related articles on the PHP Chinese website!

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