The php design pattern Builder code is as follows:
/**
* Builder mode
*
* Separates the construction of a complex object from its representation. different representations can be created using the same construction process.
*/
Class Product
{
Public $ _ type = null;
Public $ _ size = null;
Public $ _ color = null;
Public function setType ($ type)
{
Echo "set product type
";
$ This-> _ type = $ type;
}
Public function setSize ($ size)
{
Echo "set product size
";
$ This-> _ size = $ size;
}
Public function setColor ($ color)
{
Echo "set product color
";
$ This-> _ color = $ color;
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.