keywords and special variables
New,class,extends. These three, we all know.
:: The scope resolution operator (also known as Paamayim Nekudotayim) or, more simply, a pair of colons, can be used to access static members, methods, and constants. It can also be used to override members and methods in a class.
Parent and self. The parent refers to the name of the base class that the derived class refers to in the extends declaration. This avoids using the name of the base class in multiple places.
$this pseudo-variables. $this points to the current instance. $this is not necessarily the object that the method belongs to. Sometimes the code in Class A calls a static method of Class B. Reference Example: http://www.php.net/manual/zh/language.oop5.basic.php
The Static keyword. If you declare a class member or method to be static, you can access it directly without instantiating the class. However, in addition to static methods, you cannot access static members through an object. In a static method, $this is not used. Instead, use self::.
Final keyword. Can be used for classes (class) and methods (function), so that classes cannot be inherited and methods cannot be overwritten.
Properties
can be initialized, but the initialized value must be a constant. Constants are preceded by a const keyword, and the value of the constant must be a fixed value and cannot be the result of a variable, class property, or other operation, such as a function call.
Constructors and Destructors
Neither of these functions implicitly calls the base class's response function, which is not the same as the constructor mechanism of Java. To achieve such an effect, the execution must be displayed. An exception cannot be thrown in a destructor.
Abstract class: A class method declared as abstract cannot contain a concrete implementation, and an abstract class cannot be instantiated. Must be inherited before instantiating its subclasses. And the subclass's access control is the same as the abstract class, or more relaxed. An abstract class contains at least one abstract method.
interface
Using interfaces (interface), you can specify which methods a class must implement, but you do not need to define the specifics of these methods.
All methods defined must be public and the method is empty
Constants can be defined, but no attributes
The implementation of the interface (implements) must implement all methods, and multiple interfaces can be implemented (note that the method cannot have duplicate names).
Interfaces can be inherited by additional interfaces (extends)
http://www.bkjia.com/PHPjc/324430.html www.bkjia.com true http://www.bkjia.com/PHPjc/324430.html techarticle keywords and special variable new,class,extends. These three, we all know. ::, range resolution operator (also known as Paamayim Nekudotayim) or, more simply, a pair of colons, can ...