1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| class UserInfo {
public $userInfo = array();
public function addUser($userInfo) { $this->userInfo[] = $userInfo; }
public function getUserList() { print_r($this->userInfo); } }
class UserInfoDecorate {
public function makeCaps($UserInfo) { foreach ($UserInfo->userInfo as &$val) { $val = strtoupper($val); } }
}
$UserInfo = new UserInfo; $UserInfo->addUser('zhu'); $UserInfo->addUser('initphp'); $UserInfoDecorate = new UserInfoDecorate; $UserInfoDecorate->makeCaps($UserInfo); $UserInfo->getUserList();
|