3v4l.org

run code in 500+ PHP versions simultaneously
<?php $lignes = isset($_GET['lignes']) ? $_GET['lignes'] : ''; $colonnes = isset($_GET['colonnes']) ? $_GET['colonnes'] : ''; $couleur = isset($_GET['couleur']) ? $_GET['couleur'] : '#000000'; function entierPositif($v) { return $v !== '' && is_numeric($v) && $v == (int)$v && $v > 0; } ?> <form method="get" action=""> <b>Nombre de lignes (entier):</b> <input type="text" name="lignes" value="<?php echo htmlspecialchars($lignes); ?>"><br> <b>Nombre de colonnes (entier):</b> <input type="text" name="colonnes" value="<?php echo htmlspecialchars($colonnes); ?>"><br> Couleur de fond: <input type="color" name="couleur" value="<?php echo htmlspecialchars($couleur); ?>"><br> <input type="submit" value="Afficher tableau"> </form> <?php if (entierPositif($lignes) && entierPositif($colonnes)) { $l = (int)$lignes; $c = (int)$colonnes; echo "<p>Tableau de $l lignes et $c colonnes:</p>"; echo '<table border="1" cellspacing="0" style="background-color:' . htmlspecialchars($couleur) . '">'; for ($i = 0; $i < $l; $i++) { echo '<tr>'; for ($j = 0; $j < $c; $j++) { echo '<td>-</td>'; } echo '</tr>'; } echo '</table>'; } else { echo '<p>Nombre de lignes ou de colonnes pas entiers ou vide.</p>'; } ?>

preferences:
23.09 ms | 475 KiB | 4 Q