예제 #1
0
파일: circle.php 프로젝트: TRHoward/MiscPHP
function both()
{
    global $r;
    return array(area($r), perimeter($r));
}
예제 #2
0
<html lang = "en">
	<head>
		<title>Circle Functions</title>
	</head>
	
	<body>
		<?php 
$r = 5;
$h = 3;
$k = -2;
include "circle.php";
echo "Area :  " . area() . "<br />";
echo "Perimieter: " . perimeter(10) . "<br /><hr />";
list($myArea, $myPerim) = both();
echo "Both: area = " . $myArea . " and perimeter= " . $myPerim . "<br /><hr />";
$h = 3;
$k = -2;
echo "Circle with center ({$h}, {$k}): The piont (-2,-2) is " . point(-2, -2) . "<br />";
echo "Circle with center (3,-2) : The point (1,-1) is " . point(1, -1) . "<br />";
?>
		
	</body>
</html>
			<p><input type="submit" value="CALCULATE" name="calc" /></p>

		</form>




<?php 
if (isset($_POST['calc'])) {
    $length = $_POST['length'];
    $width = $_POST['width'];
    echo "length:" . $length . "<br><br>";
    echo "width:" . $width . "<br><br>";
    function perimeter($length, $width)
    {
        return 2 * ($length + $width);
    }
    $perimeter = perimeter($length, $width);
    echo "perimeter:" . $perimeter . "<br>", "<br>";
    function area($length, $width)
    {
        return $length * $width;
    }
    $area = area($length, $width);
    echo "area:" . $area;
}
?>



	</body>