源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

领悟php接口中interface存在的意义

  • 时间:2022-05-29 17:41 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:领悟php接口中interface存在的意义
可能大家都懂这些,作为不懂的我猜测了一下这个interface的意义,他就是为了后面调用的时候再调用的方法中调用实现类中interface中存在的内容,好绕口啊,写个例子留作以后看吧 pay.php
[u]复制代码[/u] 代码如下:
interface Ipay {  function withmoney();  //function withinternet(); } class Dmeng implements Ipay {  function withmoney()  {   echo "花人民币买东西";  }  function withinternet()  {   return "用网银支付";  } }
usei.php
[u]复制代码[/u] 代码如下:
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中的某个方法注释掉,发现再调用的时候,就没用了
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部