Skip to content

Instantly share code, notes, and snippets.

@darrenjaworski
Last active December 16, 2015 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenjaworski/5457696 to your computer and use it in GitHub Desktop.
Save darrenjaworski/5457696 to your computer and use it in GitHub Desktop.
Circle class - PHP

This is a simple circle class replicated in PHP from C#. - PHP file

<!DOCTYPE html>
<html>
<head>
<style>
body {
padding-top: 50px;
width: 600px;
padding: auto;
margin: auto;
}
</style>
</head>
<body>
<?php
$myCircle = $_POST['myCircle'];
$yourCircle = $_POST['yourCircle'];
function getRadius($radius)
{
return $radius;
}
function getArea($radius)
{
$area = ( M_PI * pow($radius, 2) );
return $area;
}
function getCircumference($radius)
{
$circumference = ( 2 * M_PI * $radius);
return $circumference;
}
echo 'My circle information<BR>';
echo 'My circle radius: ' .getRadius($myCircle) .'<BR>';
echo 'My circle area: ' .getArea($myCircle) .'<BR>';
echo 'My circle circumference: ' .getCircumference($myCircle) .'<BR>';
echo '<BR>*************YOUR CIRCLE************* <BR>';
echo 'Your circle information<BR>';
echo 'Your circle radius: ' .getRadius($yourCircle) .'<BR>';
echo 'Your circle area: ' .getArea($yourCircle) .'<BR>';
echo 'Your circle circumference: ' .getCircumference($yourCircle) .'<BR>';
?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<circle cx="100" cy="50" r="40" stroke="black"
stroke-width="2" fill="red"/>
</svg>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<fieldset>
<form action="circle.php" method="post">
<legend>Circle</legend>
<ul>
<label>What is the radius of my circle:</label><br>
<li><input type="number" name="myCircle" min="0" required>
</li>
<label>What is the radius of your cirlce:</label><br>
<li><input type="number" name="yourCircle" min="0" required>
</li>
<br>
<br>
<li><input type="submit" name="compute" value="compute">
</li>
</ul>
</form>
</fieldset>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment