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.



Your result can be seen below.

Result of php executing





Full code of ejercicios_1_2_3_4.php

  1. <?php
  2. //-------EJERCICIO 1, comparacion entre variables------
  3.    $a=10;   $b=20;   echo "EJERCICIO 1";   echo "\n";   if ($a > $b) {  echo "a es mayor que b";
  4.    }
  5.     else  {
  6.         
  7.         echo "a es inferior que b";
  8.     }   
  9.    echo "\n" ;
  10.    echo "\n";
  11.    
  12.  
  13. //------EJERCICIO 2, aceptacion del peso de un coche---------
  14.  
  15. $PesoVehiculo= 16;
  16. $PesoPermitido=15;
  17.  
  18. echo "EJERCICIO 2";
  19.    
  20.    echo "\n";
  21.    
  22.    
  23. //----- PESO SUPERIOR AL INDICADO---------
  24.  
  25. if ($PesoVehiculo > $PesoPermitido) {
  26.     
  27.     echo "ERROR. \n El peso maximo debe ser: $PesoPermitido";
  28. }
  29.  
  30.  
  31.  
  32. //------PESO INFERIOR AL INDICADO-----------
  33.  
  34. else {
  35.     echo "El peso del vehiculo no es el adecuado (inferior).";
  36. }
  37.  
  38.      echo "\n\n";
  39.  
  40. //-------EJERCICIO 3, respuesta a mensaje--------
  41.  
  42. $mensaje= "adiooos";
  43.     echo "EJERCICIO 3 \n";
  44.  
  45. if ($mensaje == "hola") {
  46.     
  47.     echo "Muy buenas usuario";
  48.     
  49. }
  50.  
  51. else if  ($mensaje== "adios") {
  52.     
  53.     echo "Hasta pronto";
  54.     
  55. }
  56. else 
  57. {
  58.     echo "No entiendo";
  59. }
  60.  
File Description
  • ejercicios_1_2_3_4
  • PHP Code
  • 17 May-2022
  • 977 Bytes
You can Share it: