For those beginners of the PHP language, for the PHP interface class may not be very in-depth understanding, and then we will specifically describe the PHP interface class interface usage.
In fact, their role is very simple, when a lot of people together to develop a project, may go to call someone else to write some of the class, then you will ask, how do I know how he is the implementation of a function of how to name it, this time the PHP interface class interface play a role, when we define an interface class, The way inside it is that the following subclasses must be implemented, such as:
Interface Shop
{public
function buy ($gid);
Public function sell ($gid);
Public Function view ($gid);
I declare a shop interface class, defined three methods: Buy (purchase), sell (Sell), see (view), then inherit this class all subclasses must implement these 3 methods less than one, if the subclass does not implement these words, can not run. In fact, the interface class plainly, is a class template, a class of provisions, if you belong to this category, you must follow my rules, less than one, but the specific how you do, I do not care, it is your business, such as:
Class Baseshop implements shop {public
function buy ($gid) {
echo (' you purchased the product with ID: '. $gid. ');
}
Public function Sell ($gid) {
echo (' You sold the product with ID: '. $gid. ');
}
Public Function View ($gid) {
echo (' You have viewed the product with ID: '. $gid. ');
}
You think, in a large number of people cooperation project inside, have the interface class is how convenient, so you do not have to ask others, your certain function of the method name is, of course, if you like this I have no way.