Ejemplos de Cálculos En PHP
Dejo un ejemplo de programación en PHP.
Funciona demasiado simple, solo hay que configurar las dos variables, $PrimerValor y $SegundoValor, actualmente están en 10 y 30.
<?php
# Comentarios.
# Ejemplo de programacion en PHP simple
# Haciendo simples calculos entre variables predefinidas
# Por EjemploDe.Com
$PrimerValor = 10; //Comentario: Edita el numero para cambiar el primer valor
$SegundoValor = 30; //Comentario: Edita el numero para cambiar el segundo valor
//Seccion de calculos
$suma = $PrimerValor + $SegundoValor; //Sumamos
$resta = $PrimerValor - $SegundoValor; //Restamos
$multiplicacion = $PrimerValor * $SegundoValor; //Multiplicamos
$division = $PrimerValor / $SegundoValor; //Dividimos
//A continuacion mostramos las cuentas en un formato textual
echo "<h1>Formato Textual</h1>";
echo "La <strong>suma</strong> entre <strong>".$PrimerValor."</strong> y <strong>
".$SegundoValor."</strong> es de <strong>".$suma."</strong><br/>";
echo "La <strong>resta</strong> entre <strong>".$PrimerValor."</strong> y <strong>
".$SegundoValor."</strong> es de <strong>".$resta."</strong><br/>";
echo "La <strong>multiplicacion</strong> entre <strong>".$PrimerValor."</strong> y <strong>
".$SegundoValor."</strong> es de <strong>".$multiplicacion."</strong><br/>";
echo "La <strong>division</strong> entre <strong>".$PrimerValor."</strong> y <strong>
".$SegundoValor."</strong> es de <strong>".$division."</strong><br/>"; //A continuacion mostramos las cuentas en un formato matematico
echo "<h1>Formato Matematico</h1>";
echo "".$PrimerValor." + ".$SegundoValor." = <strong>".$suma."</strong><br/>";
echo "".$PrimerValor." - ".$SegundoValor." = <strong>".$resta."</strong><br/>";
echo "".$PrimerValor." * ".$SegundoValor." = <strong>".$multiplicacion."</strong><br/>";
echo "".$PrimerValor." / ".$SegundoValor." = <strong>".$division."</strong><br/>";
?>
Este ejemplo en PHP mostraría lo siguiente
La suma entre 10 y 30 es de 40
La resta entre 10 y 30 es de -20
La multiplicacion entre 10 y 30 es de 300
La division entre 10 y 30 es de 0.333333333333
10 + 30 = 40
10 - 30 = -20
10 * 30 = 300
10 / 30 = 0.333333333333
¿Cómo citar? Pichardo, A. (s.f.). Ejemplos de Cálculos En PHP.Ejemplo de. Recuperado el 13 de Junio de 2024 de https://www.ejemplode.com/20-php/19-ejemplo_de_calculos_en_php.html
Últimos 10 comentarios
muchas gracias