Skip to content

Rectangle perimeter and area

PHP two formulas

Flowchart (ISO 5807)

StartInput w, hperimeter = 2(w + h)area = whOutput perimeterOutput areaEndFigure 1 — rectangle

Source code

PHP
function rectangle($w, $h) {
    $perimeter = 2 * ($w + $h);
    $area = $w * $h;
    echo $perimeter;
    echo $area;
}

The editor opens with this code — change it and the chart redraws.

Language
PHP
Constructs
two formulas
Topic
Input/Output
Formats
Word, Visio, draw.io, PDF, SVG

Related examples