Home >Backend Development >PHP Problem >What does php keyword mean?

What does php keyword mean?

WBOY
WBOYOriginal
2022-07-27 16:55:072472browse

PHP keywords mean characters with special meanings in syntax; keywords are used to identify the values ​​of specific data items recorded in the file. PHP keywords indicate that they have been used by the PHP language itself and cannot Words used for other purposes, such as Private, Protected, Public, static, Final, Abstract, etc.

What does php keyword mean?

The operating environment of this article: Windows 10 system, PHP version 8.1, Dell G3 computer

What does the php keyword mean

The so-called keywords are words that have been used by the language itself and cannot be used for other purposes

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

Private

Private is the core part of access control. Therefore, the properties (variables) or methods defined as Private in the class can only It can be accessed within the class. It cannot be accessed by any instance (object) or subclass of the class. Similarly, you cannot access it 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:

  • Access static methods directly through the class name plus::

  • The $this keyword cannot be used in static methods

Final

If a property (variable) is modified by Final, then the property (variable) The value cannot be changed, and if it is a function, the function cannot be overridden or overridden.

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.

Extended knowledge

Operator

The operator is used to connect in expressions Operators for different objects, different operators specify different operation methods.

Operators can be understood as built-in functions in the language, the most basic functions, and irreplaceable functions!

Operators are essentially functions. It's just that the operator needs further explanation by the compiler.

Function

A function is a group of statements that perform a task together

The difference between functions and operators:

  • Operators can only be overloaded and cannot be customized. The name of the function can be chosen casually, as long as it is an identifier; but operators cannot.

  • The function itself has a piece of code. When the program is executed, when it encounters a function, it will first push the parameters of the function onto the stack, and then jump to the code of the function to run. The operators operate directly locally.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What does php keyword mean?. 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