php 设计模式 --桥接模式
作者:互联网
php抽象类和接口的区别
https://www.cnblogs.com/vinter/p/8716685.html
什么时候适合使用 --- 多个角色配合工作:抽象角色对应具体角色;
<?php interface icar{ function Run(); } class daben implements icar{ public function Run() { echo "奔驰汽车" ; } } class aodi implements icar{ public function Run() { echo "奥迪汽车"; } } abstract class road{ public $icar; abstract function Run (); } class gaosu extends road{ function Run (){ $this->icar->Run(); echo ":在告诉路上行驶"; } } class xiaolu extends road { function Run () { $this->icar->Run(); echo ":在小路路上行驶"; } } $gaosuroad = new gaosu(); $gaosuroad->icar= new aodi(); $gaosuroad->run(); $gaosuroad = new xiaolu(); $gaosuroad->icar= new daben(); $gaosuroad->run();
标签:Run,php,gaosuroad,桥接,icar,echo,xiaolu,new,设计模式 来源: https://www.cnblogs.com/songyanan/p/12059446.html