<?php
$calc = function(){
$act = ''; $a = $b = 0;
extract($_POST);
$a = (int) $a;
$b = (int) $b;
return preg_match('~^[*/+-]$~', $act) ? eval("return $a $act $b;") : false;
};
$_SERVER['REQUEST_METHOD'] != 'POST' ?: print $calc();
?>
<form method="post">
<input type="text" name="a" />
<input type="text" name="b" />
<?php foreach (['+', '-', '*', '/'] as $act): ?>
<input type="submit" name="act" value="<?=$act?>" />
<?php endforeach; ?>
</form>