Monday, May 9, 2011

To add Two number by useing classes in php

<?php
class abc
{
   
   
 function addition ($a=0,$b=0)
 {
    
   
    return ($a + $b);  
 }

 
 
 
 function multi ($a=1, $b=1)
 {
   

  
    return ($a * $b);  
 }



 function div($a=1 , $b=1 )
 {
  
    return ($a / $b);
 }

 }

$a=new abc;
//echo $a->addition($value1 + $value2);
?>

<html>

<body>
<form method="post">
<input type="text" name="value1" value="0" />
<input type="text" name="value2" value="0" />
<input type="submit" name="submit" value="Sum" /><br />
addtion<input type="text" value="<?php echo $a->addition($_POST['value1'] + $_POST['value2']) ?>" /><br />
multiplication<input type="text" value="<?php echo $a->multi($_POST['value1'] * $_POST['value2']) ?>" /><br />
Division<input type="text" value="<?php echo $a->multi($_POST['value1']/$_POST['value2']) ?>" /><br/>
</form>
</body>
</html>

2 comments:

  1. Elance
    Freelancer
    GetACoder
    oDesk
    ScriptLance

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete