TRATAMIENTO CON NÚMEROS
Se puede realizar algunos bloques de php en el mismo código de html, POR EJEMPLO, si tenemos parte de un código:
$valor1=10,
Esto es una multiplicación: <?php echo $valor1 *=10; ?><br>
Esto es una división: <?php echo $valor1 /=10; ?><br>
Esto es un incremento: <?php echo $valor1++; ?><br>
Trabajar con decimales
Si tenemos las variables con los siguientes valores:$decimal = 15.67;
$num = 5.896;
$exponente=3;
$base=round($decimal+$num);
VARIABLES CONSTANTES:
Es una variable que almacena un valor que no cambiará.
SINTAXIS
define(NOMBRE_DE_VARIABLE, valor);
define(NOMBRE_DE_VARIABLE, valor);
MATRICES
- Son espacios de almacenamiento, al igual que las variables.
- Hay que identificarle con un nombre, mediante la sintaxis array
- Se puede almacenar varios valores a la vez.
- Es una lista ordenada vacía, y se accede a cada elemento mediante índices.
Actividad desplegar los valores de las matrices dadas
Además
de almacenar, texto, números, se puede guardar dentro de está matriz, otra
matriz
OTRA MANERA DE ASIGNAR UNA MATRIZ.
REEMPLAZAR DATOS
Puede ser en general cualquier caracter, //, $, -, &
Ejemplo
<?php
$tasaCambio = array(1, 0.73379,0.59404,8.06101,6.23689,101.968, 58.5435 );
$tasaCambio = array(
"USD" => 1,
"EUR" => 0.73379,
"GBP" => 0.59404,
"ARS" => 8.06101,
"CNY" => 6.23689,
"JPY" => 101.968,
"INR" => 58.5435
);
$nombreMoneda = array(
"USD" => "Dolar (EEUU)" ,
"EUR" => "Euro (Europa)" ,
"GBP" => "Libras (Inglaterra)" ,
"ARS" => "Peso(Argentina)" ,
"CNY" => "Yuan(China)" ,
"JPY" => "Yen (Japon)" ,
"INR" => "Rupia (India)"
);
if (!empty($_POST)) {
$valor = $_POST["valor"];
$dDesde = $_POST["desde"];
$dHasta = $_POST["hasta"];
$tasaCambioDolar = $tasaCambio["USD"] / $tasaCambio[$dDesde];
$valorUSD = $valor * $tasaCambioDolar;
$valorFinal = $valorUSD * $tasaCambio[$dHasta];
}
?>
<!DOCTYPE html>
<html>
<body bgproperties=fixed background="subportada2.jpg">
<meta charset="utf-8">
<center>
<BR><BR>
<font size=+2>CONVERTIDOR DE MONEDAS</font>
<BR><BR><BR>
<table border="1" bordercolor="silver">
<tr>
<td>Valor a calcular:</td>
<td>
<strong>
<?php echo $valor . " " . $dDesde . " - " . $nombreMoneda[$dDesde]; ?>
</strong>
</td>
</tr>
<tr>
<td>El resultado es:</td>
<td>
<strong>
<?php echo $valorFinal . " " . $dHasta . " - " . $nombreMoneda[$dHasta]; ?>
</strong>
</td>
</tr>
</center>
</table>
<BR><BR><BR><BR><BR><BR><br><BR><BR><BR><BR><BR><BR>
<pre> <a href="subportada.html" target=main><img src="inicio.png"></pre>
</body>
</html>
$tasaCambio = array(1, 0.73379,0.59404,8.06101,6.23689,101.968, 58.5435 );
$tasaCambio = array(
"USD" => 1,
"EUR" => 0.73379,
"GBP" => 0.59404,
"ARS" => 8.06101,
"CNY" => 6.23689,
"JPY" => 101.968,
"INR" => 58.5435
);
$nombreMoneda = array(
"USD" => "Dolar (EEUU)" ,
"EUR" => "Euro (Europa)" ,
"GBP" => "Libras (Inglaterra)" ,
"ARS" => "Peso(Argentina)" ,
"CNY" => "Yuan(China)" ,
"JPY" => "Yen (Japon)" ,
"INR" => "Rupia (India)"
);
if (!empty($_POST)) {
$valor = $_POST["valor"];
$dDesde = $_POST["desde"];
$dHasta = $_POST["hasta"];
$tasaCambioDolar = $tasaCambio["USD"] / $tasaCambio[$dDesde];
$valorUSD = $valor * $tasaCambioDolar;
$valorFinal = $valorUSD * $tasaCambio[$dHasta];
}
?>
<!DOCTYPE html>
<html>
<body bgproperties=fixed background="subportada2.jpg">
<meta charset="utf-8">
<center>
<BR><BR>
<font size=+2>CONVERTIDOR DE MONEDAS</font>
<BR><BR><BR>
<table border="1" bordercolor="silver">
<tr>
<td>Valor a calcular:</td>
<td>
<strong>
<?php echo $valor . " " . $dDesde . " - " . $nombreMoneda[$dDesde]; ?>
</strong>
</td>
</tr>
<tr>
<td>El resultado es:</td>
<td>
<strong>
<?php echo $valorFinal . " " . $dHasta . " - " . $nombreMoneda[$dHasta]; ?>
</strong>
</td>
</tr>
</center>
</table>
<BR><BR><BR><BR><BR><BR><br><BR><BR><BR><BR><BR><BR>
<pre> <a href="subportada.html" target=main><img src="inicio.png"></pre>
</body>
</html>

0 comentarios:
Publicar un comentario