Hello all!
Got another code that I need a helpful nudge with. I need to create a function to calculate the area of a circle. The function has to take in two arguments (a number and a string). The number is the diameter; the string is the word “diameter.” The function has to return the area of the circle or a -1 for an error. The script has to initialize test variables, call the function and display the results. I’m such a noob so don’t laugh when you see my code thus far. I appreciate any help you can offer.
<? php//
variables$diameter = 4.0;
$pi = 3.14;
$area = ($diameter * $pi);
$title = "Circle";
function circle_function (4.0, "diameter")
if ($diameter * $pi) !=$area)
{
return $area;
}
{
else
return -1;
}
if ($area == -1)
{
echo "Invalid input";
exit -1;
}
echo "<html>
<head>
<title>
$title
</title>
</head>
<body>
<h1>Area of a Circle</h1>\n";
echo circle_function();
echo "</body>
</html>";
?>