标签:设计模式 option span tle 责任链 管理 proc header admin
html
<html> <head> <meta charset="UTF-8"> <title>责任链模式</title> </head> <body> <h1>责任链模式举报</h1> <form action="09-2.php" method="post"> <select name="lev" id=""> <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"); /** * 版主 */ class Broad { protected $power = 1; protected $prev = ‘Admin‘; public function process($lev) { if ($lev <= $this->power) { echo "版主删帖"; }else{ $process = new $this->prev; $process->process($lev); } } } /** * 管理员 */ class Admin { protected $power = 2; protected $prev = ‘Police‘; public function process($lev) { if ($lev <= $this->power) { echo "封号处理"; }else{ $process = new $this->prev; $process->process($lev); } } } /** * 公安 */ class Police { protected $power; protected $prev ; public function process($lev) { echo "被公安抓了哈"; } } $lev = $_POST[‘lev‘]; $process = new Broad(); $process->process($lev);
标签:设计模式 option span tle 责任链 管理 proc header admin
原文地址:https://www.cnblogs.com/Mishell/p/12182340.html