责任链模式

<?php
class board { protected $power = 1; protected $top = 'admin'; public function process($lev){ if($lev <= $this->power){ echo '版主删帖'; } else { $top = new $this->top; $top->process($lev); } } } class admin { protected $power = 2; protected $top = 'police'; public function process($lev){ if($lev <= $this->power){ echo '管理员封账号'; } else { $top = new $this->top; $top->process($lev); } } } class police { protected $power = 3; protected $top = null; public function process($lev){ echo '抓起来'; } } //责任链模式 $lev = (int)$_POST['jubao']; $judge = new board(); $judge->process($lev);

 

posted @ 2019-05-29 16:26  zhang-san  阅读(250)  评论(0编辑  收藏  举报