php设计模式之面向过程实现举报功能实例代码
html
<html> <head> <meta charset="UTF-8"> <title>责任链模式</title> </head> <body> <h1>责任链模式举报</h1> <form action="09.php" method="post"> <select name="lev" id=""> <option value="">全部类型</option> <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[‘lev‘]; if ($lev == 1) { $process = new Broad(); $process->process(); }elseif ($lev == 2) { $process = new Admin(); $process->process(); }elseif ($lev == 3) { $process = new Police(); $process->process(); }else{ echo "一切正常"; } /** * 版主 */ class Broad { public function process() { echo "版主删帖"; } } /** * 管理员 */ class Admin { public function process() { echo "封号处理"; } } /** * 公安 */ class Police { public function process() { echo "被公安抓了"; } }
相关推荐
VanTYS 2020-04-09
zhiliang 2020-03-01
VanTYS 2020-02-03
chvnetcom 2020-01-18
taiyangshenniao 2019-12-27
THEEYE 2019-12-18
Mrwind 2019-11-03
阿亮 2019-10-26
limuxia 2012-03-23
dream00csdn 2012-03-31
oCUBONEo 2019-01-08
errcit0 2018-04-08
wyzdeng 2019-01-08
austindev 2018-11-22
jszy 2015-08-07
MicroBoy 2019-04-26
sulinux 2009-10-10