Home > Article > Backend Development > php object-oriented related
php construction method function__constructz(){
}
The destructor function__destruct(){} in php5//cannot take any parameters
static You can declare static methods and static attributes. This is stored in memory.
In PHP, static methods in a class can only access static properties, and non-static methods can only access non-static properties.
self is similar to $this, but self is used to call static properties. self::property name (does not point to any instantiated object)
final is used to define classes and methods and cannot be used to define member properties. Because final defines constants, and defining constants in PHP is define(); classes defined by final cannot be inherited. Methods marked final cannot be overridden.
define() uses this function to define constants.
const keyword to define constants in a class.
__toString() If you write this in the class, then echo can correctly print out the object (that is, which class is referenced $pag = new animal()) value.
__clone Clone A function with the same properties.
__call() This is an error-absorbing method. If you write this method in the class, then when we call a non-existent method in the class, an error will be prompted, but the program will continue to run.
__autoload() Automatic loading When developing, you often need to include and load some files. If you use this method, you don’t have to be so troublesome. It will be automatically loaded when you use it again