PHP interface and reference interface-PHP Tutorial

Source: Internet
Author: User
PHP interface and reference interface. 1. interface introduction and creation Keywords: interface2. interface reference and specification Keywords: implements Interface: a special abstract class with all member attributes being abstract, in the same procedure, 1. interface introduction and creation
Keyword: interface

2. Interface references and specifications
Keyword: implements
Interface: A special abstract class whose member attributes are all abstract. it serves as a standard in a program.
1. all classes are abstract methods.
2. you do not need to add abstract
3. the interface abstract method property is public.
4. the member attribute must be a constant.
Abstract:
1. there must be at least one abstract method in the class.
2. add abstract before the abstract method

Commonalities:
1. they cannot be instantiated and must be inherited or referenced.

2. After inheritance or reference, you must overload all abstract methods before using them.
The interface has its own creation keyword: The interface is similar to the normal class creation
Interface demo {
Const NAME = "NAME ";
Function Fun1 (); // all object methods are abstract methods. you do not need to add adstract
Function Fun2 ();
}
You can use the keyword implements to separate multiple references using commas.

1. common class reference interface example:
Class mypc implements demo, demo2, demo3 {
......
}
2. example of an abstract class reference interface:
Abstract class mypc implements demo, demo2, demo3 {
......
}
3. example of inheriting the parent class reference interface:
Class mypc extends root implements demo, demo2, demo3 {
......
}
4. interface and interface inheritance:
Interface demo3 extends demo {
......
}

Keyword: interface 2. interface reference and standard keyword: implements interface: a special abstract class with all member attributes...

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.