user input in oop php

34

<?php

class demo

{

function add($a,$b)

{   

$sum=$a+$b;

echo "Sum=".$sum."<br/>";	

}

function sub($x,$y)

{

$sub=$x-$y;

echo "Subtraction=".$sub;	

}

}

$obj= new demo();

$obj->add($_GET['f'],$_GET['s']);

$obj->sub($_GET['f'],$_GET['s']);

?>
  
<form>

Enter first number<input type="text" name="f"/><hr/>

Enter second number<input type="text" name="s"/><hr/>

<input type="submit" value="Show result"/>

</form>

Comments

Submit
0 Comments