<?php
function checkSum($a,$b){
if(is_int($a) && is_int($b)){
return $a + $b;
} elseif(is_string($a) && is_string($b)){
return $a . $b;
}
else {
echo "error";
};
}
?>
<br />
<form method="post">
<input type="text" name="num1" style="border:solid"/><br>
<input type="text" name="num2" style="border:solid"/><br>
<input type="submit" value="submit" style="text-color:red"/>
</form>
<br />
<?php
echo checkSum($_POST['num1'],$_POST['num2']);
?>