Area of Triangle Program in PHP

Area of Triangle Program in PHP. A Php program to the area of a triangle. Using this program we can run the area of a triangle in PHP programming language. Let’s look at how to use the formula to find the area of a triangle. The area formulas for all types of triangles, such as an equilateral triangle’s area, a right-angled triangle’s area, and an isosceles triangle’s area, are listed here. Also, examples of how to use Heron’s formula to find the area of a triangle with three sides.

<?php 
$base = 5;
$height = 10;
echo "area with base $base and height $height= " . ($base * $height) / 2;
?>

 

Output:

area with base 5 and height 10= 25

Base and Height in PHP

where b is the base and h is the height, is the area of a triangle. The height of a triangle is the length of the altitude from the opposite vertex to the base, and the base is any one of the sides. The base of a triangle is one of the triangle’s three sides, and it might be one of the triangle’s three lines. One side of a triangle is the base, while the other two sides are the height and hypotenuse.

Echo in PHP

echo is a statement that displays the output of a command. echo() and echo can be used with or without parentheses. echo does not produce a result. In echo, several strings can be separated by a comma (,).