Solution:
HTML File:
<html>
<head><title>A4A1</title></head>
<body bgcolor="GOLD" font type='San Sarif'>
<center><h2>Implementation of Interface and Class</h2></center>
<br/>
<hr>
<form action="a4a1.php" method='POST'>
<h3>Enter radius        :<input type='text' name='rad'><br/></h3>
<h3>Enter height        :<input type='text' name='hit'><br/></h3>
<br/>
<br/>
<pre><input type='submit' name='submit' value='Area.'>  <input type='reset' name='reset' value='reset'>
</form>
</body>
</html>
PHP Function:
NOTE: PHP function is saved as "a4a1.php"
<?php
$r=$_POST['rad'];
$h=$_POST['hit'];
define('PPI','3.1412');
Interface fun
{
        function area($r,$h);
        function volume($r,$h);
}
class cylinder implements fun
{
        function area($r,$h)
        {
         $area=(2*PPI*$r*($r+$h));
         echo "<center><h3>The area of cylinder is:     $area</font></center></h3>";
        }
        function volume($r,$h)
        {
         $v=(PPI*$r*$r*$h);
         echo "<center><h3>The volume of cylinder is:     $v</font></center></h3>";
        }
}
$o=new cylinder;
$o->area($r,$h);
$o->volume($r,$h);
?>
0 Comments