programación PHP while saregune CC 2009
definición while (mientras) Es una estructura que permite repetir instrucciones.
robotijo tarea: cruzar la calle
cruzar la calle mientras haya coches espera // Ya no hay coches. // Puedes cruzar mientras no he llegado paso adelante
while while ( hay_coches() ) { wait (5); //segundos } // wait ..sleep
while while ( hay_coches() ) { wait (5); ... }
while while ( expresión ) { instrucciones; } expresión: e. boolena instrucciones: lista.
correo
correo mientras haya correo repartelo;
correo while ( haya_correo() ){ repartir_correo(); } // y la carta?
correo coge una carta mientras tengas carta reparte carta; coge carta;
correo con carta $carta = get_carta( $saco); while ( $carta ) { repartir ($carta); $carta = get_carta( $saco) }
correo eficaz $carta = get_carta( $saco); while ( $carta ) { repartir ($carta); $carta = get_carta( $saco) } // Versión rápida while ( $carta = get_carta( $saco) ) {
consulta bd // realizamos una consulta. $rsConsulta = mysql_query($cSQL); echo "<ul>";.. while ( $dato = mysql_fetch_array( $rsConsulta ) ){ echo "<li>". $dato["nombre"] . "</li>"; } ...
WP: The Loop while (have_posts()) { the_post(); // imprimir el post actual. }
WP: The Loop while (have_posts()): the_post(); // imprimir el post actual. endwhile; if ( .... ) : ... endif
The WP-theme-style <?php while (have_posts()): the_post(); ?> <etiqueta htmls> <?php endwhile; ?> <?php if ( .... ) : algo; ?> <?php endif ?>