<?php
/**
* 工厂模式
*/
interface A{
function test();
}
class B implements A{
public function test()
{
echo 'b test'.\n;
}
}
class C implements A{
public function test()
{
echo 'c test'.\n;
// TODO: Implement test() method.
}
}
interface Create{
function create($type);
}
class MakeCreate implements Create {
public function create($type)
{
switch ($type){
case 'B';
return new B();
case 'C':
return new C();
default:
echo 'fail';
break;
}
}
}