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.
Result of php executing
Full code of Test_Lindnau.php
- <?php
- //Aufgabe a
- $Geb_Jahr = 2024;
- $Geb_Monat = 11;
- $Akt_Jahr = 2023;
- $Akt_Monat = 9;
- if($Geb_Jahr > $Akt_Jahr)
- {
- echo "Falsche Eingabe! Das Geburtsjahr liegt in der Zukunft!";
- }
- else
- {
- if($Geb_Monat == $Akt_Monat)
- {
- $Geb_Tag = 2;
- $Akt_Tag = 11;
- if($Geb_Tag <= $Akt_Tag)
- {
- $alter = $Akt_Jahr - $Geb_Jahr;
- }
- else
- {
- $alter = $Akt_Jahr - $Geb_Jahr - 1;
- }
- }
- else
- {
- if($Geb_Monat < $Akt_Monat)
- {
- $alter = $Akt_Jahr - $Geb_Jahr;
- }
- else
- {
- $alter = $Akt_Jahr - $Geb_Jahr - 1;
- }
- }
- echo $alter;
- if($alter < 18)
- {
- echo " Sie sind minderjährig";
- }
- else if($alter > 65)
- {
- echo " Sie sind Rentner";
- }
- else
- {
- echo " Sie sind erwachsen";
- }
- }
- echo " ";
- // Aufgabe b
- $a = 10; //Anzahl des auszugebenden Fibonacci Zahlen
- $fib = array();
- $fib[0] = 1;
- $fib[1] = 1;
- for($i = 1 ;$i <= $a; $i++)
- {
- $fib[$i+1] = $fib[$i-1] + $fib[$i];
- echo $fib[$i-1];
- echo " ";
- }
- ?>