废话不多说,直接上源码

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>VPS剩余价值计算器</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">

</head>
<body>
    <div class="container mt-5">
        <h1 class="mb-4">VPS剩余价值计算器</h1>
        <form method="post">
            <div class="form-group">
                <label for="purchasePrice">历史购买价格:</label>
                <input type="number" class="form-control" id="purchasePrice" name="purchasePrice" step = "0.01" required>
            </div>
            <div class="form-group">
                <label for="currentDate">当前日期:</label>
                <input type="date" class="form-control" id="currentDate" name="currentDate" value="<?php echo date("Y-m-d")?>" required>
            </div>
            <div class="form-group">
                <label for="expiryDate">到期日期:</label>
                <input type="date" class="form-control" id="expiryDate" name="expiryDate" required>
            </div>
            <div class="form-group">
                <label for="paymentFrequency">付款周期:</label>
                <select class="form-control" id="paymentFrequency" name="paymentFrequency" required>
                    <option value="yearly">年付</option>
                    <option value="halfyearly">半年付</option>
                    <option value="quarterly">季付</option>
                    <option value="monthly">月付</option>
                </select>
            </div>
            <button type="submit" class="btn btn-primary">计算剩余价值</button>
        </form>

        <?php
        if ($_SERVER["REQUEST_METHOD"] === "POST") {
            $purchasePrice = floatval($_POST["purchasePrice"]);

            $currentDate = strtotime($_POST["currentDate"]);
            $expiryDate = strtotime($_POST["expiryDate"]);
            $paymentFrequency = $_POST["paymentFrequency"];
            
            $remainingDays = floor(($expiryDate - $currentDate) / (24 * 60 * 60));
            
            $remainingMonths = floor($remainingDays/30);


            if ($paymentFrequency === "quarterly") {
                $paymentFrequency_ = "季付";
                $remainingValue = $purchasePrice/90*$remainingDays;
            } elseif ($paymentFrequency === "yearly") {
                $paymentFrequency_ = "年付";
                $remainingValue = $purchasePrice/365*$remainingDays;
            } elseif ($paymentFrequency === "halfyearly") {
                $paymentFrequency_ = "半年付";
                $remainingValue = $purchasePrice/180*$remainingDays;
            } elseif ($paymentFrequency === "monthly") {
                $paymentFrequency_ = "月付";
                $remainingValue = $purchasePrice/30*$remainingDays;
            }

            

            echo '<div class="mt-4">';
            echo '<h3>计算结果:</h3>';
            echo '<p>历史购买价格:$' . $purchasePrice . '</p>';
            echo '<p>剩余价值计算周期:' . $paymentFrequency_ . '</p>';
            echo '<p>剩余价值:$' . $remainingValue . '</p>';
            echo '</div>';
            

            echo '<div class="mt-4">';
            echo '<h3>计算过程:</h3>';
            echo '<div class="accordion" id="calculationProcess">';
            echo '<div class="card">';
            echo '<div class="card-header" id="headingOne">';
            echo '<h2 class="mb-0">';
            echo '<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">';
            echo '展开计算过程';
            echo '</button>';
            echo '</h2>';
            echo '</div>';
            echo '<div id="collapseOne" class="collapse" aria-labelledby="headingOne" data-parent="#calculationProcess">';
            echo '<div class="card-body">';
            

            echo '<p>剩余月份:' . $remainingMonths . ' 个月(剩余天数:'.$remainingDays.' 天)</p>';
            if ($paymentFrequency === "quarterly") {
                echo '<p>剩余价值 = 历史购买价格 / 90 * 剩余天数</p>';
                echo '<p>剩余价值 = $' . $purchasePrice . ' / 90 * ' . $remainingDays . ' = $' . $remainingValue . '</p>';
            } elseif ($paymentFrequency === "yearly") {
                echo '<p>剩余价值 = 历史购买价格 / 365 * 剩余天数</p>';
                echo '<p>剩余价值 = $' . $purchasePrice . ' / 365 * ' . $remainingDays . ' = $' . $remainingValue . '</p>';
            } elseif ($paymentFrequency === "halfyearly") {
                echo '<p>剩余价值 = 历史购买价格 / 180 * 剩余天数</p>';
                echo '<p>剩余价值 = $' . $purchasePrice . ' / 180 * ' . $remainingDays . ' = $' . $remainingValue . '</p>';
            }elseif ($paymentFrequency === "monthly") {
                echo '<p>剩余价值 = 历史购买价格 / 30 * 剩余天数</p>';
                echo '<p>剩余价值 = $' . $purchasePrice . ' / 30 * ' . $remainingDays . ' = $' . $remainingValue . '</p>';
            }

            
            
            echo '</div>';
            echo '</div>';
            echo '</div>';
            echo '</div>';
            echo '</div>';
        }
        ?>

    </div>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>