Understanding the meaning of the existence of interface in PHP interface

Source: Internet
Author: User

Maybe we all understand these, as do not understand I guess the meaning of this interface, he is in order to call the next time to call the implementation of the interface in the class of the content, good around the mouth ah, write an example to stay for later see
pay.php

Copy Code code as follows:
Interface Ipay
{
function Withmoney ();

function withinternet ();
}
Class Dmeng implements Ipay
{

function Withmoney ()
{
echo "Spend RMB to buy things";
}
function Withinternet ()
{
Return "Pay with net silver";
}
}


usei.php

Copy Code code as follows:
Include_once ' pay.php ';
Class Main
{
function Run ($VC)
{
$this->VC = $VC;
$this->vc->withinternet ();
echo "Yunxing";
}

}
$com = new Main ();
$com->run (new Dmeng);


That's the way it is, we annotate a method in the interface, and when we do it, it's useless.

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.