Bucle while

<?php
 $a = 0;
 while ($a < 10) {
 echo "$a<br/>";
 $a += 2;
 }

$a = 0;
 while ($a < 10) {
 if ($a % 2 == 0) {
 echo "**<br/>";
 } else {
 echo "*****<br/>";
 }
 $a++;
 }

$a = 0;
 while ($a < 10) {
 if ($a % 2 == 0) {
 ?>
 <p style="background-color: black">.......</p>
 <?php
 } else {
 ?>
 <p style="background-color: red">.......</p>
 <?php
 }
 $a++;
 }
 ?>

Publicado por

Avatar del usuario

Juan Pablo Fuentes

Formador de programación y bases de datos