<?php //set defaults $number1 = 0; $number2 = 0; $result = 0; //check the post if (isset($_POST['submit'])) { //get the values $number1 = (int) strip_tags(trim($_POST['number1'])); $number2 = (int) strip_tags(trim($_POST['number2'])); $result = (int) strip_tags(trim($_POST['result'])); //get result from model (send the values) $calc = new Calculator($number1, $number2, $result); } if ($_POST['plus']) { $result = $calc->add($number1, $number2); } else { if ($_POST['minus']) { $result = $calc->minus($number1, $number2); } else { if ($_POST['times']) { $result = $calc->mutiply($number1, $number2); } else { if ($_POST['divide']) { $result = $calc->divide($number1, $number2); } } } }