abstract class info{ protected $send = null; public function __construct($send){ $this->send = $send; } abstract public function msg($content); public function send($to,$content){ $content = $this->msg($content); $this->send->send($to,$content); } } class zn{ public function send($to,$content){ echo "给".$to."发送".$content; } } class email{ public function send($to,$content){ echo "给".$to."发送".$content; } } class sms{ public function send($to,$content){ echo "给".$to."发送".$content; } } class Ainfo extends info{ public function msg($content){ return "A".$content; } } class Binfo extends info{ public function msg($content){ return "B".$content; } } class Cinfo extends info{ public function msg($content){ return "C".$content; } } $a =new Ainfo(new zn()); echo $a->send("小孩","来呀");
php 桥接模式
最新推荐文章于 2023-04-25 18:56:19 发布