Last active
October 23, 2021 09:34
-
-
Save celestecastillo0/8126dd38f0269955f11f35e7ed2d2ad9 to your computer and use it in GitHub Desktop.
DeWeb act3 UII switch case
This file contains 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 | |
$variable=2; | |
switch($variable) { | |
case 1: | |
echo '$variable es igual a 1.'; | |
break; | |
case 2: | |
echo '$variable es igual a 2.'; | |
break; | |
case 3: | |
echo '$variable es igual a 3.'; | |
break; | |
default: | |
echo '$variable no es igual a 1, 2 o 3.'; | |
} | |
echo "<br> Celeste Castillo Flores"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
En conclusión, se trata de un stwitch en este caso tenemos varias alternativas para realizar una acción determinada según el valor tomado por una variable, la indicación break se usa siempre para cerrar el case , se asigna un valor a la variable que debemos hacer ,para esto debemos saber que un case no puede tener mas de un valor, la instrucción defaul se usa cuando ninguno de tu case se adhiere a el valor asignado a tu variable , se usa la etiqueta echo o print para imprimir mensajes en pantalla para el usuario ,se usa código php ,aunque de igual manera sirve en html ,switch sirve para tener una sintaxis y estructura con varias opciones.