<?php /** **建造者模式:消除其他对象复杂的创建过程 *****/ class UserInfo{ protected $_age; protected $_name; protected $_prov; public function __construct(){ } public function setAge($age){ $this->_age = $age; } public function setName($name){ $this->_name = $name; } public function setProv($prov){ $this->_prov = $prov; } public function getMan(){ echo $this->_age.$this->_name.$this->prov; } } class Building{ protected $man = ‘‘; public function __construct(){ $this->man = new UserInfo(); } public function buildman($array){ $this->man->setAge($array[‘age‘); $this->man->setAge($array[‘name‘); $this->man->setAge($array[‘prov‘); } public function getman(){ $this->man->getMan(); } }
本文出自 “王尼美的成人之路” 博客,请务必保留此出处http://8335914.blog.51cto.com/8325914/1613673
原文地址:http://8335914.blog.51cto.com/8325914/1613673