My php code printed in browser windows as written.
Here is code:
class calcu
{
function add($n1,$n2)
{
echo $n1."+".$n2." = ".($n1+$n2);
}
function sub($n1,$n2)
{
echo $n1."-".$n2." = ".($n1-$n2);
}
function mul($n1,$n2)
{
echo $n1.“x”.$n2." = ".($n1*$n2);
}
function div($n1,$n2)
{
echo $n1."/".$n2." = ".($n1/$n2);
}
}
$k=new calcu();
switch($_POST[‘calculate’])
{
case ‘+’:
{
$k->add($_POST[‘val1’],$_POST[‘val2’]);break;
}
case ‘-’:
{
$k->sub($_POST[‘val1’],$_POST[‘val2’]);break;
}
case ‘x’:
{
$k->mul($_POST[‘val1’],$_POST[‘val2’]);break;
}
case ‘/’:
{
$k->div($_POST[‘val1’],$_POST[‘val2’]);break;
}
}
?>
Calculator
1st Value :  2nd Value :   
               
Developer:-
               Saad Ehsan.
Code is working if i used it as separate php file and link it with html document but requirement is to embed in same document but
Why its being printed insteed of performing tasks ?