PHP头条
热点:

简单的一个php工厂模式代码-PHP源码


1. [PHP]代码

radius = $radius;
	}
	public function getArea() {
		return $this->radius * $this->radius * pi();
	}
}

class Square {
	private $side = 0;
	public function __construct($side) {
		$this->side = $side;
	}
	public function getArea() {
		return $this->side * $this->side;
	}
}

$shape = Shape::getShape('circle', 10);
echo $shape->getArea();
echo "\n";

$shape = Shape::getShape('square', 2);
echo $shape->getArea();
echo "\n";

www.phpzy.comtrue/php/32878.htmlTechArticle简单的一个php工厂模式代码-PHP源码 1. [PHP]代码 radius = $radius;}public function getArea() {return $this->radius * $this->radius * pi();}}class Square {private $side = 0;public function __construct($side) {$this->side = $side...

相关文章

PHP之友评论

今天推荐