<?php
// ************************************ 工厂模式 ***************************************
// 代码来源:http://laravelacademy.org/post/769.html 在此基础上稍作修改
interface SuperModuleInterface {
//接口
//超能力激活方法
public function activate();
}
//X-超能量
class XPower implements SuperModuleInterface {
public function activate() {
echo "this is XPower"."<br>";
}
}
//终极炸弹
class UltraBomb implements SuperModuleInterface {
public function activate() {
echo "this is UltraBomb"."<br>";
}
}
//超人类
class Superman {
protected $module; //模块
public function __construct
PHP 依赖注入(DI)和控制反转(IoC)简单理解
最新推荐文章于 2022-08-02 08:19:03 发布