diff --git a/Practicas/Practicas_PHP/codigo/comprobacion_variables_session.php b/Practicas/Practicas_PHP/codigo/comprobacion_variables_session.php new file mode 100644 index 0000000..158ff8a --- /dev/null +++ b/Practicas/Practicas_PHP/codigo/comprobacion_variables_session.php @@ -0,0 +1,73 @@ + array_diff($claves_a_comprobar, array_keys($___SESSION) +// Forma 1 => array_diff($claves_a_comprobar, array_keys($___SESSION)) === [] +// Forma 2 => empty(array_diff($claves_a_comprobar, array_keys($___SESSION))) +// Forma 3 => count(array_diff($claves_a_comprobar, array_keys($___SESSION))) === 0 + +/***** Ejemplo *****/ +$___SESSION = [ + 'cero' => 0, + 'uno' => '1', + 'dos' => 'dos', + 'tres' => 3, + 'cuatro' => '4', +]; + +/*----- Caso 1: Todas las claves existen -----*/ +$claves_a_comprobar = ['uno', 'dos', 'tres']; + +// Forma 1 +if(array_diff($claves_a_comprobar, array_keys($___SESSION)) === []) { + echo 'OK-[]' . PHP_EOL; +} +else { + echo 'NOOOO-[]' . PHP_EOL; +} + +// Forma 2 +if(empty(array_diff($claves_a_comprobar, array_keys($___SESSION)))) { + echo 'OK-EMPTY' . PHP_EOL; +} +else { + echo 'NOOOO-EMPTY' . PHP_EOL; +} + +// Forma 3 +if(count(array_diff($claves_a_comprobar, array_keys($___SESSION))) === 0) { + echo 'OK-COUNT' . PHP_EOL; +} +else { + echo 'NOOOO-COUNT' . PHP_EOL; +} + +/*----- Caso 2: No existen todas las claves -----*/ +$claves_a_comprobar = ['uno', 'two', 'tres']; + +// Forma 1 +if(array_diff($claves_a_comprobar, array_keys($___SESSION)) === []) { + echo 'OK-[]' . PHP_EOL; +} +else { + echo 'NOOOO-[]' . PHP_EOL; +} + +// Forma 2 +if(empty(array_diff($claves_a_comprobar, array_keys($___SESSION)))) { + echo 'OK-EMPTY' . PHP_EOL; +} +else { + echo 'NOOOO-EMPTY' . PHP_EOL; +} + +// Forma 3 +if(count(array_diff($claves_a_comprobar, array_keys($___SESSION))) === 0) { + echo 'OK-COUNT' . PHP_EOL; +} +else { + echo 'NOOOO-COUNT' . PHP_EOL; +} \ No newline at end of file diff --git a/Practicas/Practicas_PHP/codigo/cookies/INTRO_COOKIES_PHP.php b/Practicas/Practicas_PHP/codigo/cookies/INTRO_COOKIES_PHP.php new file mode 100644 index 0000000..690777f --- /dev/null +++ b/Practicas/Practicas_PHP/codigo/cookies/INTRO_COOKIES_PHP.php @@ -0,0 +1,21 @@ + diff --git a/Practicas/Practicas_PHP/codigo/cookies/INTRO_COOKIES_PHP2.php b/Practicas/Practicas_PHP/codigo/cookies/INTRO_COOKIES_PHP2.php new file mode 100644 index 0000000..032e7cc --- /dev/null +++ b/Practicas/Practicas_PHP/codigo/cookies/INTRO_COOKIES_PHP2.php @@ -0,0 +1,16 @@ + diff --git a/Practicas/Practicas_PHP/ejercicios/Plantilla Examen/busqueda.php b/Practicas/Practicas_PHP/ejercicios/Plantilla Examen/busqueda.php index 48b58a1..4a820cd 100755 --- a/Practicas/Practicas_PHP/ejercicios/Plantilla Examen/busqueda.php +++ b/Practicas/Practicas_PHP/ejercicios/Plantilla Examen/busqueda.php @@ -4,7 +4,9 @@
- + ' + : '' ?>