<?php/**** Builder mode: Eliminate complex creation process for other objects *****/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 = ';p ublic 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 ();}}
This article is from the "Wang Nimei Adult Road" blog, so be sure to keep this source http://8335914.blog.51cto.com/8325914/1613673
PHP design Pattern-builder mode