Code analysis for adaptation such as PHP adapter mode

黄舟
Release: 2023-03-06 16:42:01
Original
1577 people have browsed it

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();
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!