本文主要和大家介绍了php简单装饰器模式实现与用法,结合具体实例形式分析了php装饰器模式的原理、实现与使用方法,需要的朋友可以参考下,希望能帮助到大家。
_weapon = $weapon;
}
public function cost(){
return $this->_weapon->cost() + $this->_price;
}
public function descriptions(){
return $this->_weapon->descriptions().$this->_descriptions;
}
}
//力量属性
class Strength extends Property{
protected $_price = 30;
protected $_descriptions = '+ Strength';
}
//敏捷属性
class Agility extends Property{
protected $_price = 50;
protected $_descriptions = '+ Agility';
}
//智力属性
class Intellect extends Property{
protected $_price = 20;
protected $_descriptions = '+ Intellect';
}
$weapon = new Agility(new Strength(new Strength(new Glave())));
echo $weapon->cost();
echo $weapon->descriptions();相关推荐:
dmSOBC SHOP网店系统由北京时代胜腾信息技术有限公司(http://www.webzhan.com)历时6个月开发完成,本着简单实用的理念,商城在功能上摒弃了外在装饰的一些辅助功能,尽可能的精简各项模块开发,做到有用的才开发,网店V1.0.0版本开发完成后得到了很多用户的使用并获得了好评,公司立即对网店进行升级,其中包括修正客户提出的一些意见和建议,现对广大用户提供免费试用版本,如您在使用
立即学习“PHP免费学习笔记(深入)”;










