3v4l.org

run code in 500+ PHP versions simultaneously
<?php include 'conexion.php'; // Función para calcular Días de Ingreso y Nota automáticamente function calcularDiasYNota($fechaIngreso, $fechaInventario) { $dateIngreso = new DateTime($fechaIngreso); $dateInv = new DateTime($fechaInventario); $dias = $dateIngreso->diff($dateInv)->days; if ($dias < 15) { $nota = "Menor a 15 días"; $badgeClass = "bg-success"; // Verde } elseif ($dias <= 29) { $nota = "Entre 15 y 29 días"; $badgeClass = "bg-warning text-dark"; // Amarillo } else { $nota = "Mayor a 30 días"; $badgeClass = "bg-danger"; // Rojo } return [ 'dias' => $dias, 'nota' => $nota, 'badge' => $badgeClass ]; } // Obtener registros $sql = "SELECT * FROM inventario ORDER BY fecha_ingreso ASC"; $result = $conn->query($sql); ?> <!DOCTYPE html> <html lang="es"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Control de Inventario</title> <!-- Bootstrap 5 CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <!-- FontAwesome Iconos --> <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet"> <style> body { background-color: #f8f9fa; } .table-header { background-color: #1a252f; color: white; } .card { border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); } </style> </head> <body> <div class="container-fluid py-4 px-4"> <div class="d-flex justify-content-between align-items-center mb-4"> <h2><i class="fa-solid fa-boxes-stacked me-2"></i>Control de Inventario de Equipos</h2> <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#modalIngreso"> <i class="fa-solid fa-plus me-1"></i> Registrar Nuevo Artículo </button> </div> <!-- Tabla de Registros --> <div class="card"> <div class="card-body p-0"> <div class="table-responsive"> <table class="table table-hover table-striped align-middle mb-0"> <thead class="table-header"> <tr> <th>FECHA INVENTARIO</th> <th>FECHA INGRESO</th> <th>SERIE</th> <th>ARTÍCULO</th> <th>ESTADO</th> <th>COMENTARIO</th> <th class="text-center">DÍAS INGRESO</th> <th class="text-center">NOTA</th> </tr> </thead> <tbody> <?php if ($result->num_rows > 0): ?> <?php while($row = $result->fetch_assoc()): $calculo = calcularDiasYNota($row['fecha_ingreso'], $row['fecha_inventario']); ?> <tr> <td><?= date("d/m/Y", strtotime($row['fecha_inventario'])) ?></td> <td><?= date("d/m/Y", strtotime($row['fecha_ingreso'])) ?></td> <td><code class="fw-bold text-dark"><?= htmlspecialchars($row['serie']) ?></code></td> <td><span class="badge bg-secondary"><?= htmlspecialchars($row['articulo']) ?></span></td> <td> <?php if($row['estado'] == 'LIMPIEZA'): ?> <span class="badge bg-info text-dark">LIMPIEZA</span> <?php else: ?> <span class="badge bg-primary">EN BODEGA</span> <?php endif; ?> </td> <td><?= htmlspecialchars($row['comentario']) ?></td> <td class="text-center fw-bold"><?= $calculo['dias'] ?></td> <td class="text-center"> <span class="badge <?= $calculo['badge'] ?> px-3 py-2"> <?= $calculo['nota'] ?> </span> </td> </tr> <?php endwhile; ?> <?php else: ?> <tr> <td colspan="8" class="text-center py-4 text-muted">No hay registros guardados.</td> </tr> <?php endif; ?> </tbody> </table> </div> </div> </div> </div> <!-- Modal Formulario de Registro --> <div class="modal fade" id="modalIngreso" tabindex="-1" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <form action="guardar.php" method="POST"> <div class="modal-header"> <h5 class="modal-title">Registrar Artículo</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <div class="mb-3"> <label class="form-label">Fecha Inventario</label> <input type="date" name="fecha_inventario" class="form-control" value="<?= date('Y-m-d') ?>" required> </div> <div class="mb-3"> <label class="form-label">Fecha Ingreso</label> <input type="date" name="fecha_ingreso" class="form-control" required> </div> <div class="mb-3"> <label class="form-label">Serie</label> <input type="text" name="serie" class="form-control" placeholder="Ej: 2700050952..." required> </div> <div class="mb-3"> <label class="form-label">Artículo</label> <select name="articulo" class="form-select" required> <option value="MPOS">MPOS</option> <option value="PAX A920PRO">PAX A920PRO</option> <option value="RAPI BAC">RAPI BAC</option> </select> </div> <div class="mb-3"> <label class="form-label">Estado</label> <select name="estado" class="form-select" required> <option value="EN BODEGA">EN BODEGA</option> <option value="LIMPIEZA">LIMPIEZA</option> <option value="REPARACION">REPARACIÓN</option> </select> </div> <div class="mb-3"> <label class="form-label">Comentario</label> <textarea name="comentario" class="form-control" rows="2" placeholder="Ej: SIN CAJA / ESTANTE ABAJO"></textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancelar</button> <button type="submit" class="btn btn-success">Guardar Registro</button> </div> </form> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </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.5.100.0060.00516.88
8.5.90.0080.00617.04
8.5.80.0090.00916.84
8.5.70.0090.00817.17
8.5.60.0040.00416.93
8.5.50.0080.00916.74
8.5.40.0080.00416.80
8.5.30.0090.00516.93
8.5.20.0100.00816.66
8.5.10.0090.00716.73
8.5.00.0090.00816.90
8.4.250.0150.00519.82
8.4.240.0070.00719.77
8.4.230.0100.01019.79
8.4.220.0060.00619.72
8.4.210.0130.00719.66
8.4.200.0080.00319.75
8.4.190.0090.01219.79
8.4.180.0160.00619.75
8.4.170.0080.01119.78
8.4.160.0060.00519.86
8.4.150.0100.00919.91
8.4.140.0070.00617.98
8.4.130.0110.00717.88
8.4.120.0060.00518.14
8.4.110.0090.00418.10
8.4.100.0100.00918.15
8.4.90.0050.01018.08
8.4.80.0080.00818.09
8.4.70.0060.00318.14
8.4.60.0070.00218.05
8.4.50.0060.00318.07
8.4.40.0050.00417.96
8.4.30.0050.00417.92
8.4.20.0060.01017.90
8.4.10.0120.00717.89
8.3.330.0150.00818.42
8.3.320.0110.01118.59
8.3.310.0060.00418.61
8.3.300.0050.00718.59
8.3.290.0100.00818.64
8.3.280.0080.00418.58
8.3.270.0090.00516.80
8.3.260.0080.01017.01
8.3.250.0090.00716.91
8.3.240.0060.00316.92
8.3.230.0040.00417.00
8.3.220.0040.00516.91
8.3.210.0060.00316.99
8.3.200.0050.00316.86
8.3.190.0060.00517.00
8.3.180.0020.00616.86
8.3.170.0070.00416.86
8.3.160.0060.00217.00
8.3.150.0030.00516.92
8.3.140.0050.00316.96
8.3.130.0060.00317.00
8.3.120.0060.00616.92
8.3.110.0120.00716.92
8.3.100.0080.00516.89
8.3.90.0050.00416.93
8.3.80.0050.00416.93
8.3.70.0100.00716.89
8.3.60.0090.00216.89
8.3.50.0090.00716.89
8.3.40.0130.00818.09
8.3.30.0090.00218.14
8.3.20.0130.00818.09
8.3.10.0070.00518.21
8.3.00.0110.01018.08
8.2.330.0060.00618.27
8.2.320.0050.00418.21
8.2.310.0050.00318.18

preferences:
31.88 ms | 829 KiB | 5 Q