1<?PHP2 /*3 * Bridging mode4 * 5 * Reference: http://blog.csdn.net/jhq0113/article/details/454417936 * 7 */8 /** Abstract Role Abstract Path9 * Class abstractroadTen */ One Abstract classAbstractroad { A Public $icar; - Abstract functionRun (); - } the /** Specific Highways - * Class speedroad - */ - classSpeedroadextendsAbstractroad { + functionRun () { - $this->icar->Run (); + Echo": On the freeway. "; A } at } - /** Village Street - * Class Street - */ - classStreetextendsAbstractroad { - functionRun () { in $this->icar->Run (); - Echo": On the village streets. "; to } + } - /** Abstract Automotive Interface the * Interface ICar * */ $ InterfaceICar {Panax Notoginseng functionRun (); - } the /** Jeep + * Class Jeep A */ the classJeepImplementsICar { + functionRun () { - Echo"Jeep Run"; $ } $ } - /** Car - * Class Car the */ - classCarImplementsICar {Wuyi functionRun () { the Echo"Car Run"; - } Wu } - //------------------------Bridge mode test code------------------ About $speedRoad=Newspeedroad (); $ $speedRoad->icar =NewCar (); - $speedRoad-Run (); - Echo"; - $street=NewStreet (); A $street->icar =NewJeep (); + $street->run ();
Bridging mode-design mode-PHP version