예제 #1
0
                return $this->a / $this->b;
                break;
            default:
                return "Please Select One Operation...";
        }
    }
    function getresult($a, $b, $c)
    {
        $this->a = $a;
        $this->b = $b;
        return $this->checkoperation($c);
    }
}
$calculator = new calculator();
if (isset($_POST['submit'])) {
    $answer = $calculator->getresult($_POST['number1'], $_POST['number2'], $_POST['operator']);
}
?>

<form method="post">
<table align="center">
    <tr>
        <td><strong>Result :<?php 
echo $answer;
?>
<strong></td>
    </tr>
    <tr>
        <td>Enter 1st Number</td>
        <td><input type="number" name="number1" required="true"></td>
    </tr>