本文整理汇总了PHP中Rectangle::set_height方法的典型用法代码示例。如果您正苦于以下问题:PHP Rectangle::set_height方法的具体用法?PHP Rectangle::set_height怎么用?PHP Rectangle::set_height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle::set_height方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Rectangle
<?php
require_once 'classes/rectangle.php';
$r1 = new Rectangle();
$r1->set_width(5);
$r1->set_height(4);
echo 'R1<br>Area: ' . $r1->get_area() . '<br>Perimeter: ' . $r1->get_perimeter();
$r2 = new Rectangle(8, 6);
echo '<br>R1<br>Area: ' . $r2->get_area() . '<br>Perimeter: ' . $r2->get_perimeter();
示例2: set_radius
//access parent's protected method
return parent::get_area();
}
//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>";