Static also includes: Ordinary member: A normal member is a static member of an object: A static member is a keyword that belongs to a class:StaticThe self keyword: represents the class inside a class, without adding $ in the static method cannot call the ordinary member in the ordinary method can call the static
Example:classfenbi{ Public $length; The length of the chalk Public Static $color; The color of the chalkStatic functionShow () {Echo"Chalk color is:". Self::$color; } functionXianshi () {Echo"Show:". Self::$color; }}$f=NewFenbi (); Create an object first$f-length; Use object to call ordinary member Fenbi::$color= "Red"; Calling a static member using the class name Fenbi::Show ();$f->xianshi ();
abstract Abstract class keyword abstraction features: Can not be instantiated, can only be inherited purposes: in order to derive subclasses, control subclasses Abstract class dog{ public$name; function Jiao () { echo "Bark"; }} class extends dog{ }$dnew Dog ();
interface: An extremely abstract class interface cannot contain member variables, only member method member methods can have no function body interface keywords:InterfaceThe class that implements the interface must implement all the methods inside the interfaceInterfaceiusb{functionread (); Read the methodfunctionwrite (); Method of writing} The driver class of the mouseclassMouseImplementsiusb{functionRead () {Echo"Mouse clicked"; } functionwrite () {Echo"Give the Mouse an instruction"; }} keyboard driver classclassJianpanImplementsiusb{functionRead () {Echo"Keyboard entered the content"; } functionwrite () {Echo"Give keyboard Instructions"; }}$m=NewMouse ();$m-write ();$j=NewJianpan ();$j-read (); API interface for common interface
PHP Object-oriented static and abstract, interface