Last active
August 17, 2022 21:43
-
-
Save iddar/427059397c231376e261ef5329b7c5f6 to your computer and use it in GitHub Desktop.
Ejercicio
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 | |
var_dump($_POST); | |
$total = 0; | |
if (isset($_POST['operador'])) { | |
$op = $_POST['operador']; | |
if ($op == "divi") { | |
$total = $_POST['izq'] / $_POST['derc']; | |
} elseif ($op == "suma") { | |
$total = $_POST['izq'] + $_POST['derc']; | |
} else { | |
$total = -1; | |
} | |
} | |
?> |
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
<pre> | |
<?php | |
var_dump($_POST); | |
$total = 0; | |
if (isset($_POST['operador'])) { | |
$op = $_POST['operador']; | |
switch ($op) { | |
case 'divi': | |
$total = $_POST['izq'] / $_POST['derc']; | |
break; | |
case 'suma': | |
$total = $_POST['izq'] + $_POST['derc']; | |
break; | |
case 'resta': | |
$total = $_POST['izq'] - $_POST['derc']; | |
break; | |
case 'multi': | |
$total = $_POST['izq'] * $_POST['derc']; | |
break; | |
default: | |
$total = -1; | |
break; | |
} | |
} | |
?> | |
</pre> | |
<h1>Calculadora</h1> | |
<p>Total: <?= $total ?></p> | |
<form action="/calc.php" method="POST"> | |
<input | |
type="text" | |
name="izq" | |
placeholder="Escribe un valor"> | |
<select name="operador" id=""> | |
<option value="suma">Suma</option> | |
<option value="resta">Resta</option> | |
<option value="multi">Multiplicacion</option> | |
<option value="divi">Divicion</option> | |
</select> | |
<input type="text" name="derc" placeholder="Escribe un valor"> | |
<!-- comentario: esto es un boton ↓ --> | |
<input type="submit" value="Calcular"> | |
</form> |
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
<h1>Ciclos</h1> | |
<?php | |
$compras = [ | |
// indice => valor | |
'leche' => true, | |
'huevos' => false, | |
'pan' => true, | |
'tortillas' => true, | |
]; | |
foreach ($compras as $indice => $valor) { | |
$compras[$indice] = isset($_POST[$indice]); | |
} | |
?> | |
<form action="/ciclo.php" method="POST"> | |
<ul> | |
<?php foreach($compras as $indice => $valor): ?> | |
<li> | |
<input type="checkbox" name="<?= $indice ?>" | |
<?= $valor ? 'checked' : '' ?> | |
> | |
<?= $indice ?> | |
<!-- $condicion ? ...positivo... : ...negativo.. --> | |
<?= $valor ? '- Si hay' : '- No hay' ?> | |
</li> | |
<?php endforeach; ?> | |
</ul> | |
<input type="submit" value="Actualizar"> | |
</form> |
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 | |
var_dump($_POST); | |
var_dump([15,2,3]); | |
$contacto1 = [ | |
'nombre' => 'iddar', | |
'lenguaje' => 'php', | |
'edad' => 33, | |
]; | |
$contacto2 = [ | |
'nombre' => 'Yazmani', | |
'lenguaje' => 'html', | |
'edad' => 35, | |
]; | |
$agenda = [$contacto1, $contacto2]; | |
// var_dump($contacto); | |
echo "El contacto sabe: ".$agenda[1]['lenguaje']; | |
?> |
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 | |
$nombreUsuario = $_POST["nombre"]; | |
?> | |
<pre> | |
<?php var_dump($_POST["nombre"]) ?> | |
</pre> | |
<h1>Estamos saludando</h1> | |
<p>Deja tu nombre para saludarte.</p> | |
<p>Hola <?=$nombreUsuario ?></p> | |
<form action="/hola.php" method="post"> | |
<fieldset> | |
<label for="nombre">Nombre:</label> | |
<input type="text" name="nombre" /> | |
</fieldset> | |
<input type="submit" value="Enviar" /> | |
</form> |
Author
iddar
commented
Aug 16, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment