Home>Article>Backend Development> Detailed explanation of how to implement the adapter pattern in PHP

Detailed explanation of how to implement the adapter pattern in PHP

墨辰丷
墨辰丷 Original
2018-05-21 11:17:26 1433browse

This article mainly introduces the simple adapter mode implemented by PHP, and analyzes the implementation skills and calling methods of the PHP adapter mode based on specific examples. Friends in need can refer to it

The details are as follows:

'; } } //类适配器模式 class Adapter implements Target{ private $adatee; public function __construct(Adatee $adatee){ $this->adatee = $adatee; } public function simpleMethod1(){ echo $this->adatee->simpleMethod1(); } public function simpleMethod2(){ echo $this->adatee->simpleMethod12(); } } //客户端接口 class Client{ public static function main(){ $adapter = new Adapter(new Adatee()); $adapter->simpleMethod1(); } } Client::main();

Related recommendations:

PHP Design PatternsAdapterMode

About PHP design pattern-Adaptermethod detailed explanation

PHP simpleAdapterIntroduction to the pattern

The above is the detailed content of Detailed explanation of how to implement the adapter pattern in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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