<?php
$operations = ['+', '-', '*', '/'];
$op1 = null;
$op2 = null;
if (isset($_POST['op1']) && isset($_POST['op2'])) {
   if (in_array($_POST['op'], $operations)) {
        $op1 = (float)$_POST['op1'];
        $op2 = (float)$_POST['op2'];
        switch ($_POST['op']){
            case '+':
                $res = $op1 + $op2;
                break;
            case '-':
                $res = $op1 - $op2;
                break;
            case '*':
                $res = $op1 * $op2;
                break;
            case '/':
                 if ($op2 == 0) {
                 echo 'На ноль делить нельзя!';
                 break;
                 } else $res = $op1 / $op2;
                break;
        }
   } else {
       $res = 'error!';
    }
}?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Calculator</title>
</head>
<body>
<form action="calc.php" method="post">
    <input type="text" name="op1" value="<?php echo $op1; ?>"/>
    <select name="op">
        <?php foreach ($operations as $op): ?>
            <option value="<?php echo $op; ?>"><?php echo $op; ?></option>
        <?php endforeach; ?>
    </select>
    <input type="text" name="op2" value="<?php echo $op2; ?>"/>
    <br>
    <?php if(isset($res)): ?>
        <p>Result: <?php echo $res; ?></p>
    <?php endif; ?>
    <input type="submit" value="calc!" />
</form>
</body>
</html>