责任链模式
<?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);