find the area of a triangle in php

To find the area of a triangle in PHP, you need to know the length of its base and height. Here's an example code that calculates the area of a triangle:

main.php
<?php
$base = 10;
$height = 5;
$area = 0.5 * $base * $height;
echo "The area of the triangle is: " . $area;
?>
111 chars
7 lines

In this example, we have a base of 10 units and a height of 5 units. We then calculate the area of the triangle by multiplying the base by the height, dividing by 2, and storing the result in the $area variable. Finally, we output the result using the echo statement.

related categories

gistlibby LogSnag