php桥接设计模式

<?php  
  //桥接模式
  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,'<br>','内容是',$content;
      }
 }
 class email{
     public function send($to,$content){
        echo 'email给',$to,'<br>','内容是',$content;
     }
 }
  class sms{
     public function send($to,$content){
        echo 'sms给',$to,'<br>','内容是',$content;
     }
 }
 class commoninfo extends info{
      public function msg($content){
            return '普通'.$content;
      }
 }
  class warninfo extends info{
      public function msg($content){
            return '紧急'.$content;
      }
 }
  class dangerinfo extends info{
      public function msg($content){
            return '特急'.$content;
      }
 }
 //用站内信发普通信息
 $commoninfo=new commoninfo(new zn());
 $commoninfo->send('小明','该去吃饭了');
 //用手机发送特急信息 
 $dangerinfo=new dangerinfo(new sms());
 $dangerinfo->send('小刚','紧急回家');
原文地址:https://www.cnblogs.com/kangshuai/p/5800176.html