Как передать данные с html в php и обратно?
https://developer.mozilla.org/ru/docs/Web/API/Fetc...
На кнопку результата навешиваете обработчик, в нем получив результат
document.getElementsByName("answer")[0].value = data;
Получилось после объединения в 1 php файл

<?php
$result = "";

function calculate($value)
{
    return eval("return ".$value.";");
}

if (isset($_POST["answer"])) 
{
    $result = calculate($_POST["answer"]);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/style.css">
</head>
<body>
    <div class="wrapper">
        <div class="flex-block">
            <div class="gui">
                <form name="calc" method="post">
                    <input class="answer" type="text" name="answer" value="<?php print($result); ?>" autocomplete="off">
                    <input class="button" type="button" value="1" onclick="form.answer.value += '1';">
                    <input class="button" type="button" value="2" onclick="calc.answer.value += '2'">
                    <input class="button" type="button" value="3" onclick="calc.answer.value += '3'">
                    <input class="button operator" type="button" value="+" onclick="calc.answer.value += '+'">
                
                    <input class="button" type="button" value="4" onclick="calc.answer.value += '4'">
                    <input class="button" type="button" value="5" onclick="calc.answer.value += '5'">
                    <input class="button" type="button" value="6" onclick="calc.answer.value += '6'">
                    <input class="button operator" type="button" value="-" onclick="calc.answer.value += '-'">
                
                    <input class="button" type="button" value="7" onclick="calc.answer.value += '7'">
                    <input class="button" type="button" value="8" onclick="calc.answer.value += '8'">
                    <input class="button" type="button" value="9" onclick="calc.answer.value += '9'">
                    <input class="button operator" type="button" value="x" onclick="calc.answer.value += '*'">
                
                    <input class="button clear" type="button" name="clear" value="c" onclick="calc.answer.value = ''">
                    <input class="button" type="button" value="0" onclick="calc.answer.value += '0'">
                    <input class="button" type="submit" value="=">
                    <input class="button operator" type="button" value="/" onclick="calc.answer.value += '/'">
                </form>
            </div>
        </div>
    </div>
</body>
</html>