PHP常用模式
/**简单工厂模式**/<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title></title>
</head>
<body>
<?php
interface IUser{
function getName();
}
class User implements IUser{
public function getName(){
return "jack";
}
}
class UserFactory{
public static function Create(){
return new User();
}
}
$u = UserFactory::Create();
echo($u->getName());
?>
</body>
</html>
页:
[1]