/* Here is an example of Product mode */
interface iProduct{
public function realCreate();
}
class Product1{
public function action(){
echo " here is product 1";
}
}
class Product2{
public function action(){
echo "this is product 2";
}
}
class Product1Creator implements iProduct{
public $id;
public function realCreate(){
return new Product1();
}
}
class Product2Creator implements iProduct{
public $id;
public function realCreate(){
return new Product2();
}
}
class ProductFactory{
public function create($what){
$create = $what."Creator";
return $create = new $create();
}
}
$create = new ProductFactory();
$instance = $create->create("Product1");
$instance->id = 11;
$instance->realCreate()->action();