Test_Lindnau_a - 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 Test_Lindnau_a.php

  1.  
  2. <?php
  3.  
  4.     $Geb_Jahr = "a";
  5.     $Geb_Monat = 11;
  6.     $Akt_Jahr = 2023;
  7.     $Akt_Monat = 9;
  8.     
  9.     if($Geb_Jahr > $Akt_Jahr)
  10.     {
  11.         echo "Falsche Eingabe! Das Geburtsjahr liegt in der Zukunft!";
  12.     }
  13.     else 
  14.     {
  15.         if($Geb_Monat == $Akt_Monat)
  16.         {
  17.             $Geb_Tag = 2;
  18.             $Akt_Tag = 11;
  19.         
  20.             if($Geb_Tag <= $Akt_Tag)
  21.             {
  22.                 $alter = $Akt_Jahr - $Geb_Jahr;
  23.             }
  24.             else
  25.             {
  26.                 $alter = $Akt_Jahr - $Geb_Jahr - 1;
  27.             }
  28.         }
  29.         else
  30.         {
  31.             if($Geb_Monat < $Akt_Monat)
  32.             {
  33.                 $alter = $Akt_Jahr - $Geb_Jahr;
  34.             }
  35.             else
  36.             {
  37.                 $alter = $Akt_Jahr - $Geb_Jahr - 1;
  38.             }
  39.         }
  40.     
  41.         echo $alter;
  42.     
  43.         if($alter < 18)
  44.         {
  45.             echo "  Sie sind minderjährig";
  46.         }
  47.         else if($alter > 65)
  48.         {
  49.             echo "  Sie sind Rentner";
  50.         }
  51.         else
  52.         {
  53.             echo "  Sie sind erwachsen";
  54.         }
  55.     }
  56. ?>
File Description
  • Test_Lindnau_a
  • PHP Code
  • 11 Sep-2023
  • 1.07 Kb
You can Share it: