///inheritance//subclass can inherit everything from the parent class//Features: Single-inheritance///function rewrite//polymorphism//When the parent class reference points to a subclass instance, because the child class overrides the method of the parent class, the parent class reference behaves differently when calling the method//If a method requires a parent class argument, Can give a subclass object//static//ordinary member//ordinary member is the object of//static member//static member belongs to the class//keyword: static//self keyword: in the class to represent the class//In a static method cannot call ordinary members// Ability to invoke static members in normal methodsClass Fenbi{public $length;//Length of chalkpublic static $color;//Color of chalkThe static function show () {echo "Chalk color is:". Self:: $color;} function Xianshi () {echo "shows:". Self:: $color;}} $f = new Fenbi ();//Create an object first$f->length;//Use objects to invoke ordinary membersFenbi:: $color = "Red";//Call a static member with a class nameFenbi::show (); $f->xianshi ();//abstraction//abstract class: Keyword abstract//features: cannot be instantiated, can only be inherited//purpose: In order to derive subclasses, control subclassesAbstract class Dog{public $name; function jiao () {echo "Bark";}} Class Jinmao extends dog{} $d = new Dog ();/ /interface//abstract class//interface cannot contain member variables, only member methods//Member methods can have no function body//interface keyword: interface//implements the interface class, must implement all the methods inside the interfaceInterface Iusb{function read ();//Read the methodfunction write ();//method of writing}//Mouse driver classClass Mouse implements Iusb{function read () {echo "Mouse clicked";} function write () {echo "gives the mouse an instruction";}}//Keyboard driver classClass Jianpan implements Iusb{function read () {echo "keyboard entered content";} function write () {echo "to keyboard instruction";}} $m = new Mouse (); $m->write (); $j = new Jianpan (); $j->read ();//interface: API
10.25 (PM) Start one months 21 days (abstract)