PHPAdapter patternCode analysis for adaptation
'; } } interface Targetable { /** * Source 类中同名的方法 */ function action(); /** * 需要给 Source 类新增的方法 */ function action2(); } /** * 适配器类 */ class Adapter extends Source implements Targetable { public function action2() { echo 'call action2', '
'; } } // test code $ad = new Adapter(); $ad->action(); $ad->action2();
The above is the detailed content of Code analysis for adaptation such as PHP adapter mode. For more information, please follow other related articles on the PHP Chinese website!