本文整理汇总了PHP中Rectangle::perimeter方法的典型用法代码示例。如果您正苦于以下问题:PHP Rectangle::perimeter方法的具体用法?PHP Rectangle::perimeter怎么用?PHP Rectangle::perimeter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle::perimeter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Rectangle
<?php
require_once "rectangle.php";
require_once "square.php";
$rect1 = new Rectangle(2, 7);
echo $rect1->area();
echo "\n";
echo $rect1->perimeter();
echo "\n";
$rect2 = new Rectangle(3, 4);
echo $rect2->area();
echo "\n";
echo $rect2->perimeter();
echo "\n";
$square1 = new Square(2);
echo $square1->area();
echo "\n";
echo $square1->perimeter();
echo "\n";
$square1 = new Square(3);
echo $square1->area();
echo "\n";
echo $square1->perimeter();
echo "\n";
?>
?>
示例2: Rectangle
<?php
require_once 'rectangle.php';
require_once 'square.php';
// Test your new class by creating an instance of Rectangle with various heights and widths.
$rekt_one = new Rectangle(7, 14);
$rekt_two = new Rectangle('5', '10');
$rekt_three = new Rectangle(33.33, 66.66);
$square_one = new Square(4);
// Calling the area method should correctly display the product of height and width.
var_dump($rekt_one->area());
var_dump($rekt_one->perimeter());
// var_dump($rekt_two->area());
// var_dump($rekt_three->area());
var_dump($square_one->perimeter());
var_dump($square_one->area());
示例3: Rectangle
<?php
require_once "rectangle.php";
require_once "square.php";
$rectangle = new Rectangle(4, 8);
$square = new Square(41);
echo $rectangle->area() . PHP_EOL;
echo $rectangle->perimeter() . PHP_EOL;
echo $square->area() . PHP_EOL;
echo $square->perimeter() . PHP_EOL;
示例4: Rectangle
<?php
require_once 'square.php';
require_once 'rectangle.php';
$rectangle = new Rectangle(8, 9);
echo $rectangle->area();
$rectangle = new Rectangle(8, 9);
echo $rectangle->perimeter();
$square = new Square(8, 9);
echo $square->perimeter();
$square = new Square(8, 9);
echo $square->area();
示例5: Square
<?php
require_once "rectangle.php";
require_once "square.php";
$squr = new Square(10, 30);
$area = $squr->equalarea() . " sq.";
echo $area . PHP_EOL;
$perimeter = $squr->perimeter() . " long.";
echo $perimeter . PHP_EOL;
$rect = new Rectangle(10, 30);
$area = $rect->area() . " sq.";
echo $area . PHP_EOL;
$perimeter = $rect->perimeter() . " long.";
echo $perimeter . PHP_EOL;
示例6: Rectangle
<?php
require_once 'rectangle.php';
require_once 'square.php';
$rectangle = new Rectangle(10, 10);
echo $rectangle->area() . PHP_EOL;
echo "The area of a rectangle with height of {$rectangle->getHeight()} and width of {$rectangle->getWidth()} is {$rectangle->area()} " . PHP_EOL;
echo "The perimeter of a rectangle with height of {$rectangle->getHeight} and width of {$rectangle->getWidth()} is {$rectangle->perimeter()} " . PHP_EOL;
// $square = new Square(5);
// echo "The area of a square with height of {$square->height} is {$square->area()} " . PHP_EOL;
// echo "The perimeter of a square with height of {$square->height} is {$square->perimeter()} " . PHP_EOL;