Some thoughts on the beginner PHP interface

Source: Internet
Author: User

Just learn some of the advanced PHP, the first encounter PHP interface problem, is very puzzled.

1<?PHP2     Interfaceicaneat () {3Piblicfunctioneat ();4}://defines an interface that can be associated with a class that does not require the content implementation of the method defined5     classHuman Implement icaneat{6          Public functionEat ($food){7             Echo"Human is eating".$food;8}//A class must implement the method defined inside if it is associated with an interface. 9     }Ten     $obj=NewHuman (); One?>

The above is a shorthand code. It now seems that its main use is to standardize code and to facilitate the development of many people in large-scale development.

It also involves a polymorphic feature, an important feature in object-oriented. That is, the interface is actually a rule on the class, since you this class and I related, spicy, you have to follow my rules. In the development of many people, we need to set a framework, norms and the like. But the method is not limited. That means you have to define my method, but how to do it, you think.

Classes related to the same interface, using their interface-defined methods, but are different implementations, which is polymorphic, that is, the same code, different implementations. This is the characteristic of polymorphism.

Well, first write so much, I am still a slag, the content is very rookie, the expression is also very rotten, I hope you have a lot of advice, thank you!

Some thoughts on the beginner PHP interface

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.