3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Step 1: Connect to the database $conn = new mysqli("localhost", "root", "", "customer_db"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Step 2: Handle form submission if ($_SERVER["REQUEST_METHOD"] == "POST") { $customer_name = $_POST['customer_name']; $email = $_POST['email']; $phone_number = $_POST['phone_number']; $account_type = $_POST['account_type']; $principal = $_POST['principal']; // Calculate interest based on account type $interest = 0; if ($account_type == "Saving") { $interest = $principal * 0.06; // 6% interest } elseif ($account_type == "Fixed Deposit") { $interest = $principal * 0.10; // 10% interest } // Insert data into the database $sql = "INSERT INTO customers (customer_name, email, phone_number, account_type, principal, interest) VALUES ('$customer_name', '$email', '$phone_number', '$account_type', '$principal', '$interest')"; if ($conn->query($sql) === TRUE) { echo "Customer data inserted successfully!"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } } ?> <!DOCTYPE html> <html> <head> <title>Customer Management</title> </head> <body> <h1>Customer Management Form</h1> <!-- Step 3: Form to input data --> <form method="POST" action=""> <label>Customer Name:</label> <input type="text" name="customer_name" required><br><br> <label>Email:</label> <input type="email" name="email" required><br><br> <label>Phone Number:</label> <input type="text" name="phone_number" required><br><br> <label>Account Type:</label> <select name="account_type" required> <option value="Saving">Saving</option> <option value="Current">Current</option> <option value="Fixed Deposit">Fixed Deposit</option> </select><br><br> <label>Principal Amount:</label> <input type="number" name="principal" required><br><br> <button type="submit">Submit</button> </form> <h2>Customer Details</h2> <!-- Step 4: Display data --> <?php $sql = "SELECT * FROM customers"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table border='1'> <tr> <th>Customer Name</th> <th>Email</th> <th>Phone Number</th> <th>Account Type</th> <th>Principal</th> <th>Interest</th> </tr>"; while ($row = $result->fetch_assoc()) { echo "<tr> <td>{$row['customer_name']}</td> <td>{$row['email']}</td> <td>{$row['phone_number']}</td> <td>{$row['account_type']}</td> <td>{$row['principal']}</td> <td>{$row['interest']}</td> </tr>"; } echo "</table>"; } else { echo "No customer records found!"; } $conn->close(); ?> </body> </html>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.20.0160.00721.27
8.4.10.0360.01317.47
8.3.150.0100.01017.25
8.3.140.0350.01016.57
8.3.130.0300.00616.71
8.3.120.0270.00816.69
8.3.110.0300.01116.61
8.3.100.0330.01316.84
8.3.90.0340.01116.55
8.3.80.0340.00716.48
8.3.70.0380.00716.52
8.3.60.0390.00616.68
8.3.50.0390.00616.62
8.3.40.0390.00717.29
8.3.30.0290.00317.50
8.3.20.0310.00617.46
8.3.10.0190.01117.55
8.3.00.0120.00617.64
8.2.270.0150.00416.57
8.2.260.0180.01416.60
8.2.250.0250.01316.56
8.2.240.0320.00316.61
8.2.230.0340.00416.51
8.2.220.0280.00616.62
8.2.210.0230.01016.69
8.2.200.0260.00616.66
8.2.190.0240.00716.73
8.2.180.0260.01316.61
8.2.170.0320.00917.52
8.2.160.0290.00717.70
8.2.150.0170.01717.31
8.2.140.0340.00417.41
8.2.130.0300.01017.27
8.2.120.0260.01517.58
8.2.110.0380.00317.18
8.2.100.0300.01317.48
8.2.90.0410.00417.54
8.2.80.0310.00717.36
8.2.70.0230.00817.24
8.2.60.0180.01117.47
8.2.50.0110.00717.58
8.2.40.0210.01117.21
8.2.30.0110.00817.54
8.2.20.0170.00517.46
8.2.10.0210.00417.51
8.2.00.0280.00617.03

preferences:
27.21 ms | 403 KiB | 5 Q