<?php
class Admin {
public function __construct() {
if($this->top === null) {
return;
}
$this->toper = new $this->top();
}php
public function proc($danger) {
if($danger <= $this->power) {
$this->doProc();
} else {
$this->toper->proc($danger);
}
}
}this
class Banzhu extends Admin {
protected $power = 1;
protected $top = 'Police';io
protected function doProc() {
echo '刪帖';
}
}function
class Police extends Admin {
protected $power = 2;
protected $top = 'Guoan';class
public function doProc() {
echo '抓人';
}
}top
class Guoan extends Admin {
protected $power = 3;
protected $top = null;co
public function doProc() {
echo '滅口';
}
}new
$danger = 3;return
$admin = new Banzhu();
$admin->proc($danger);
echo "<pre>";
print_r($admin);struct