Maybe everyone knows this, but as someone who doesn’t understand, I guessed the meaning of this interface. It is to call the content that exists in the interface in the implementation class in the method that is called later. It’s so confusing. I’ll leave it with an example. Let’s take a look at it later
pay.php
Copy code The code is 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 online banking";
}
}
usei.php
Copy code The code is 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);
Just like the above , we commented out a certain method in the interface, and found that it was useless when we called it again
http://www.bkjia.com/PHPjc/327878.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327878.htmlTechArticleMaybe everyone knows this. As someone who doesn’t understand, I guessed the meaning of this interface. It is for later calling When calling, call the method that exists in the interface in the implementation class...