PHP interface and Reference Interface _php Tutorial

Source: Internet
Author: User
1, the introduction and creation of the interface
Keyword: interface

2, the interface Reference and specification
Keyword: implements
Interface: A special abstract class in which the member attributes are all abstract, and the function of the norm in the program
1. All the abstract methods in the class
2, abstract method before you do not add abstract
3. Interface Abstract Method property is public
4. The member property must be a constant
Abstract:
1. There is at least one abstract method in the class
2, abstract method before the need to add abstract

Common:
1, can not be instantiated by itself, must be inherited or referenced

2. After inheriting or referencing, all abstract methods need to be overloaded before they can be used
The interface has its own creation keyword: interface is similar to the creation of a normal class
Interface Demo {
Const name= "name";
function Fun1 ();//object methods are all abstract methods, the front does not need to add adstract
function Fun2 ();
}
The interface can use keywords: implements multiple references and separate them with commas.

1, common class reference interface example:
Class MyPC implements demo, Demo2, demo3{
......
}
2, abstract class Reference interface example:
Abstract class MyPC implements demo, Demo2, demo3{
......
}
3, inherit the parent class reference interface Coexistence Example:
Class MyPC extends Root implements demo, Demo2, demo3{
......
}
4. Interface and interface inheritance:
Interface Demo3 extends demo{
......
}

http://www.bkjia.com/PHPjc/486152.html www.bkjia.com true http://www.bkjia.com/PHPjc/486152.html techarticle 1, the introduction of the interface and the creation of keywords: interface 2, interface reference and canonical keyword: implements interface: A member property is all abstract special abstract class, in the program with ...

  • Related Article

    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.