Sesion 2

18
OPERADORES Y ESTRUCTURAS DE CONTROL EN PHP INSTRUCTOR: MARCO ANTONIO ANDRADE

Transcript of Sesion 2

Page 1: Sesion 2

OPERADORES Y ESTRUCTURAS DE CONTROL EN PHP

INSTRUCTOR: MARCO ANTONIO ANDRADE

Page 2: Sesion 2

RUTA DE APRENDIZAJE

DEFINICIÓN DE PHP VARIABLES OPERADORES

ESTRUCTURAS DE CONTROLARREGLOSFUNCIONES

CONEXIÓN A BD

Page 3: Sesion 2

<? -- OPERADORES DE COMPARACIÓN -- ?>

Los operadores de comparación se utilizan, como su nombre lo indica, para hacer comparaciones entre valores que necesitan desempeñar un papel en nuestro código.

Page 4: Sesion 2

<? -- OPERADORES DE COMPARACIÓN -- ?>

Page 5: Sesion 2

<? -- OPERADORES DE INCREMENTO Y DECREMENTO -- ?>

Los operadores de decremento o incremento son de gran utilidad en la programación, sobre todo porque ahorran tiempo, esfuerzo y código.

BUCLES: es un tipo de estructura de control que permite repetir una o

más sentencias múltiples veces.

Page 6: Sesion 2

<? -- OPERADORES DE INCREMENTO Y DECREMENTO -- ?>

Page 7: Sesion 2

<? -- OPERADORES LÓGICOS-- ?>

Los operadores lógicos son de extrema utilidad a la hora de decidir si un valor y otro o un valor u otro, cumplen con ciertas condiciones. De nuevo, la utilidad de estos operadores los veremos cuando veamos las estructuras de control.

Page 8: Sesion 2

<? -- OPERADORES LÓGICOS-- ?>

Page 9: Sesion 2

IF- ELSE – ELSEIFOPERADORES CONDICIONALES

<?-- OPERADORES CONDICIONALES-- ?>

"Si me gustan los chocolates me los como, sino, los vendo, sino, los regalo"

Page 10: Sesion 2

<?-- OPERADORES CONDICIONALES-- ?><?php

$a = 3;$b = 1;

if($a < $b){echo "\$a es menor que \$b<BR>";echo "El valor de \$a es $a y el de \$b es $b";

}

elseif($a>$b){echo "\$a es mayor que \$b<BR>";echo "El valor de \$a es $a y el valor de \$b es $b";

}

else{echo "\$a es igual que \$b<BR>";echo "El valor de \$a es $a y el valor de \$b es $b";

}?>

Page 11: Sesion 2

WHILEOPERADORES CONDICIONALES

<?-- OPERADORES CONDICIONALES-- ?>

"Mientras sea de día, tengo que trabajar"

Page 12: Sesion 2

<?-- OPERADORES CONDICIONALES-- ?>

<?php$a = 1;while($a < 11){echo $a."<BR>";$a++;

}?>

Page 13: Sesion 2

DO…WHILEOPERADORES CONDICIONALES

<?-- OPERADORES CONDICIONALES-- ?>

"Haz la limpieza, mientras aún es de día"

Page 14: Sesion 2

<?-- OPERADORES CONDICIONALES-- ?>

<?php$a = 1;do{echo $a."<BR>";$a++;}while($a<=10)

?>

Page 15: Sesion 2

FOROPERADORES CONDICIONALES

<?-- OPERADORES CONDICIONALES-- ?>

"Para todos estos niños, reparte estos caramelos"

Page 16: Sesion 2

<?-- OPERADORES CONDICIONALES-- ?>

<?phpfor($i = 0; $i <= 10; $i++){echo "Esta es la fila ".$i;echo "<BR>";}

?>

Page 17: Sesion 2

SWITCHOPERADORES CONDICIONALES

<?-- OPERADORES CONDICIONALES-- ?>

"Como un ferrocarril cambiando de vía"

Page 18: Sesion 2

<?-- OPERADORES CONDICIONALES-- ?><?php

$nombre = "Eva";switch($nombre){case "Adan":

echo "El nombre es Adán";break;case "Abel":

echo "El nombre es Abel";break;case "Eva":

echo "El nombre es Eva";break;default:

echo "No hay nombre que concuerde";}echo "<BR>Esto está fuera de SWITCH";

?>