This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dia = 'Martes'; | |
| switch ($dia) { | |
| case 'Lunes': | |
| echo "Hoy es Lunes"; | |
| break; | |
| case 'Martes': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| for ($i=0; $i <=10 ; $i++) { | |
| if ($i==5) { | |
| continue ; | |
| } | |
| echo "$i <br>"; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $i = 0; | |
| while (++$i){ | |
| switch($i){ | |
| case 5: | |
| echo "He llegado a 5 </br>"; | |
| break; // Finaliza unicamente switch | |
| case 10: | |
| echo "He llegado a 10 </br>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $arreglo = array(1, 2, 3, 4); | |
| foreach ($arreglo as $valor){ | |
| echo "$valor <br>"; | |
| } | |
| foreach ($arreglo as $posicion=> $valor){ | |
| echo "Posicion: $posicion Valor: $valor <br>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| for ($numero = 1; $numero <= 10; $numero++) { | |
| echo $numero; | |
| } | |
| /** Resultado: | |
| * | |
| * 12345678910 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $numero = 0; | |
| do { | |
| echo $numero; | |
| } while ($numero > 0); | |
| /** Resultado: | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $numero = 1; | |
| while ($numero <= 10){ | |
| echo $numero . "<br>"; | |
| $numero++; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dia = "Sabado"; | |
| if ( $dia == "Lunes" ) { | |
| echo "Hoy es Lunes"; | |
| }elseif ( $dia == "Martes" ){ | |
| echo "Hoy es Martes"; | |
| }elseif ( $dia == "Miercoles" ){ | |
| echo "Hoy es Miercoles"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $edad = 19; | |
| if ( $edad >= 18 ) { | |
| echo "Es mayor de edad"; | |
| }else{ | |
| echo "Es mejor de edad"; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $a = 1; | |
| $b = 5; | |
| if ($a < $b) { | |
| echo "a es menor que b"; | |
| } | |
| ?> |