jinquan26 发表于 2017-3-4 11:28:20

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]
查看完整版本: PHP常用模式