pay.php
复制代码 代码如下:
interface Ipay
{
function withmoney();
//function withinternet();
}
class Dmeng implements Ipay
{
function withmoney()
{
echo "花人民币买东西";
}
function withinternet()
{
return "用网银支付";
}
}
usei.php
复制代码 代码如下:
include_once 'pay.php';
class main
{
function run($vc)
{
$this->vc = $vc;
$this->vc->withinternet();
echo "yunxing";
}
}
$com= new main();
$com->run(new Dmeng);
就是上面那样,我们将interface中的某个方法注释掉,发现再调用的时候,就没用了
上一篇:php中抽象类与接口的区别
下一篇:CURL状态码有哪些