ejercicios_1_2_3_4 - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of ejercicios_1_2_3_4.php
- <?php
- //-------EJERCICIO 1, comparacion entre variables------
- $a=10; $b=20; echo "EJERCICIO 1"; echo "\n"; if ($a > $b) { echo "a es mayor que b";
- }
- else {
- echo "a es inferior que b";
- }
- echo "\n" ;
- echo "\n";
- //------EJERCICIO 2, aceptacion del peso de un coche---------
- $PesoVehiculo= 16;
- $PesoPermitido=15;
- echo "EJERCICIO 2";
- echo "\n";
- //----- PESO SUPERIOR AL INDICADO---------
- if ($PesoVehiculo > $PesoPermitido) {
- echo "ERROR. \n El peso maximo debe ser: $PesoPermitido";
- }
- //------PESO INFERIOR AL INDICADO-----------
- else {
- echo "El peso del vehiculo no es el adecuado (inferior).";
- }
- echo "\n\n";
- //-------EJERCICIO 3, respuesta a mensaje--------
- $mensaje= "adiooos";
- echo "EJERCICIO 3 \n";
- if ($mensaje == "hola") {
- echo "Muy buenas usuario";
- }
- else if ($mensaje== "adios") {
- echo "Hasta pronto";
- }
- else
- {
- echo "No entiendo";
- }