-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcondicionales.php
More file actions
66 lines (53 loc) · 1.23 KB
/
condicionales.php
File metadata and controls
66 lines (53 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/* Los condicionales son iguales a otros lenguajes */
$autenticado = true;
$admin = false;
if($autenticado && $admin ) {
echo "Usuario autenticado correctamente <br>";
} else {
echo "Usuario no autenticado, inicia sesión <br>";
}
// If anidados...
$cliente = [
'nombre' => 'Juan',
'saldo' => 0,
'informacion' => [
'tipo' => 'Regular'
]
];
echo "<br>";
if( !empty($cliente) ) {
echo "El Arreglo de cliente no esta vacio <br>";
if($cliente['saldo'] > 0) {
echo "El Cliente tiene saldo disponible <br>";
} else {
echo "No hay saldo <br>";
}
}
echo "<br>";
// else if
if($cliente['saldo'] > 0 ) {
echo "El Cliente tiene saldo <br>";
} else if ($cliente['informacion']['tipo'] === 'Premium') {
echo "El Cliente es Premium <br>";
} else {
echo "No hay cliente definido o no tiene saldo o no es premium <br>";
}
// Switch.
echo "<br>";
$tecnologia = 'HTML';
switch ($tecnologia) {
case 'PHP':
echo "PHP, un excelente lenguaje!";
break;
case 'JavaScript':
echo "Genial, el lenguaje de la web";
break;
case 'HTML':
echo 'Maquetados pro';
break;
default:
echo "Lenguaje desconocido";
break;
}
?>