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

  1.  
  2. <?php
  3.     
  4.     //Aufgabe a
  5.     
  6.     $Geb_Jahr = 2024;
  7.     $Geb_Monat = 11;
  8.     $Akt_Jahr = 2023;
  9.     $Akt_Monat = 9;
  10.     
  11.     if($Geb_Jahr > $Akt_Jahr)
  12.     {
  13.         echo "Falsche Eingabe! Das Geburtsjahr liegt in der Zukunft!";
  14.     }
  15.     else 
  16.     {
  17.         if($Geb_Monat == $Akt_Monat)
  18.         {
  19.             $Geb_Tag = 2;
  20.             $Akt_Tag = 11;
  21.         
  22.             if($Geb_Tag <= $Akt_Tag)
  23.             {
  24.                 $alter = $Akt_Jahr - $Geb_Jahr;
  25.             }
  26.             else
  27.             {
  28.                 $alter = $Akt_Jahr - $Geb_Jahr - 1;
  29.             }
  30.         }
  31.         else
  32.         {
  33.             if($Geb_Monat < $Akt_Monat)
  34.             {
  35.                 $alter = $Akt_Jahr - $Geb_Jahr;
  36.             }
  37.             else
  38.             {
  39.                 $alter = $Akt_Jahr - $Geb_Jahr - 1;
  40.             }
  41.         }
  42.     
  43.         echo $alter;
  44.     
  45.         if($alter < 18)
  46.         {
  47.             echo "  Sie sind minderjährig";
  48.         }
  49.         else if($alter > 65)
  50.         {
  51.             echo "  Sie sind Rentner";
  52.         }
  53.         else
  54.         {
  55.             echo "  Sie sind erwachsen";
  56.         }
  57.     }
  58.     
  59.     echo "                                                                    ";
  60.     
  61.     // Aufgabe b
  62.     
  63.     $a = 10;  //Anzahl des auszugebenden Fibonacci Zahlen
  64.     $fib = array();
  65.     
  66.     $fib[0] = 1;
  67.     $fib[1] = 1;
  68.             
  69.     for($i = 1 ;$i <= $a; $i++)
  70.     {
  71.         $fib[$i+1] = $fib[$i-1] + $fib[$i];
  72.         echo $fib[$i-1];
  73.         echo "     ";
  74.     }
  75. ?>
File Description
  • Test_Lindnau
  • PHP Code
  • 11 Sep-2023
  • 1.46 Kb
You can Share it: