10.25 (PM) Start one months 21 days (abstract)

Source: Internet
Author: User

///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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.