本文整理汇总了PHP中Rectangle::calc_area方法的典型用法代码示例。如果您正苦于以下问题:PHP Rectangle::calc_area方法的具体用法?PHP Rectangle::calc_area怎么用?PHP Rectangle::calc_area使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle::calc_area方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_radius
}
//set radius
public function set_radius($r)
{
$this->radius = $r;
}
//get radius
public function get_radius($r)
{
return $this->radius;
}
}
$rect = new Rectangle();
$rect->set_height(5);
$rect->set_width(4);
$rect->calc_area();
echo "This object is a " . get_class($rect) . " and has an area of " . $rect->get_area();
echo "<br>";
$circ = new Circle();
$circ->set_radius(4);
$circ->calc_area();
echo "This object is a " . get_class($circ) . " and has an area of " . $circ->get_area();
echo "<br>";
$circ2 = new Circle();
$circ2->set_radius(6);
$circ2->calc_area();
echo "This object is a " . get_class($circ2) . " and has an area of " . $circ2->get_area();
echo "<br>";
echo "We now have " . Shape::$num_rect . " rectangles and " . Shape::$num_circ . " circles! <br>";
$circ2 = NULL;
echo "We now have " . Shape::$num_rect . " rectangles and " . Shape::$num_circ . " circles! <br>";