您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
设计模式-面向过程完成举报功能
发布时间:2017-11-30 09:22:27编辑:雪饮阅读()
html:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<h1>面向过程</h1>
<form action="index.php" method="post">
<select name="jubao">
<option value="1">粗口</option>
<option value="2">黄赌毒</option>
<option value="3">分裂国家</option>
</select>
<button type="submit">举报</button>
</form>
</body>
</html>
php:
<?php
header('content-type:text/html;charset=utf-8');
$lev=$_POST['jubao']+0;
//版主
class board{
public function process(){
echo '版主删帖';
}
}
//管理员
class admin{
public function process(){
echo '管理员直接封号';
}
}
//警察
class police{
public function process(){
echo '抓起来';
}
}
if($lev==1){
$judge=new board();
$judge->process();
}
else if($lev==2){
$judge=new admin();
$judge->process();
}
else{
$judge=new police();
$judge->process();
}
?>
关键字词:设计模式
上一篇:设计模式-简单工厂