当前位置: 首页>>代码示例>>PHP>>正文


PHP Rectangle::perimeter方法代码示例

本文整理汇总了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";
?>
 ?>
开发者ID:wbreiding,项目名称:Codeup_Exercises,代码行数:26,代码来源:shapes_test.php

示例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());
开发者ID:j-beere,项目名称:Codeup_Exercises,代码行数:16,代码来源:shapes_test.php

示例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;
开发者ID:sjmrt,项目名称:codeup-web-exercises,代码行数:10,代码来源:shapes_test.php

示例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();
开发者ID:aer3934,项目名称:Codeup-Web-Exercises,代码行数:12,代码来源:shapes_test.php

示例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;
开发者ID:Yeasayer,项目名称:codeup_web_exercises,代码行数:14,代码来源:shapes_area.php

示例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;
开发者ID:Reni789,项目名称:Exercises,代码行数:11,代码来源:shapes_test.php


注:本文中的Rectangle::perimeter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。