lernen prog-p added (nicht alles) 1/2
This commit is contained in:
21
progp/lernen/zusammenfassung_ka1/for-schleife.php
Normal file
21
progp/lernen/zusammenfassung_ka1/for-schleife.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
for ($i=0; $i < 10; $i++) {
|
||||
echo "Diese Schleife durschlief schon ".$i." mal diesen Code!<br>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
34
progp/lernen/zusammenfassung_ka1/if-else-elseif.php
Normal file
34
progp/lernen/zusammenfassung_ka1/if-else-elseif.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
$variable_name="Daniel";
|
||||
|
||||
if ($variable_name=="Daniel") {
|
||||
echo "Dein Name ist Daniel!";
|
||||
}
|
||||
|
||||
|
||||
if ($variable_name=="Daniel") {
|
||||
echo "Dein Name ist Daniel!";
|
||||
} else {
|
||||
echo "Dein Name ist nicht Daniel!";
|
||||
}
|
||||
|
||||
if ($variable_name=="Daniel") {
|
||||
echo "Dein Name ist Daniel!";
|
||||
} elseif ($variable_name=="Timo") {
|
||||
echo "Dein Name ist Timo!";
|
||||
} else {
|
||||
echo "Dein Name ist weder Daniel noch Timo!";
|
||||
}
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
61
progp/lernen/zusammenfassung_ka1/operatoren.php
Normal file
61
progp/lernen/zusammenfassung_ka1/operatoren.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
/*Rechen Operatoren*/
|
||||
$plus= 1+2; // = 3
|
||||
|
||||
$minus= 2-1; // = 1
|
||||
|
||||
$mal= 1*2; // = 2
|
||||
|
||||
$geteilt= 1/2;
|
||||
|
||||
/* Vergleich Operatoren*/
|
||||
$groesser= 2>1; // = true
|
||||
|
||||
$kleiner= 1<2; // = true
|
||||
|
||||
$gleich= 1==1; // = true
|
||||
|
||||
$ungleich= 1!=2; // = true
|
||||
|
||||
/*Logische Operatoren */
|
||||
|
||||
$und= true && true; // = true
|
||||
|
||||
$oder= true || false; // = true
|
||||
|
||||
$nicht=! true; // = false
|
||||
|
||||
|
||||
$zahl5=5;
|
||||
$zahl5+=7; /* Addiert der Zahl 7 und gibt den neuen Wert zurück */
|
||||
echo $zahl5."<br>";
|
||||
$zahl5-=3; /* Subtrahiert die Zahl 3 und gibt den neuen Wert zurück */
|
||||
echo $zahl5."<br>";
|
||||
$zahl5*=3; /* Multipliziert die Zahl mit 3 und gibt den neuen Wert zurück */
|
||||
echo $zahl5."<br>";
|
||||
$zahl5/=9; /* Dividiert die Zahl durch 9 und gibt den neuen Wert zurück */
|
||||
echo $zahl5."<br>";
|
||||
|
||||
$a++;
|
||||
|
||||
$a--;
|
||||
|
||||
|
||||
|
||||
$zahl_1 = $zahl_1 + 1;
|
||||
|
||||
$zahl_1 += 1;
|
||||
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
24
progp/lernen/zusammenfassung_ka1/sontstiges.php
Normal file
24
progp/lernen/zusammenfassung_ka1/sontstiges.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form action="PHP_Datei.php">
|
||||
<input type="text" name="input_name" id="name">
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
$name = $_REQUEST['input_name'];
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
26
progp/lernen/zusammenfassung_ka1/switch-case.php
Normal file
26
progp/lernen/zusammenfassung_ka1/switch-case.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
$variable_name="Daniel";
|
||||
|
||||
switch ($variable_name) {
|
||||
case "Daniel":
|
||||
echo "Dein Name ist Daniel!";
|
||||
break;
|
||||
case "Timo":
|
||||
echo "Dein Name ist Timo!";
|
||||
break;
|
||||
default:
|
||||
echo "Dein Name ist weder Daniel noch Timo!";
|
||||
}
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
33
progp/lernen/zusammenfassung_ka1/variablen.php
Normal file
33
progp/lernen/zusammenfassung_ka1/variablen.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
|
||||
/* STRING */
|
||||
$name="Daniel";
|
||||
|
||||
/* GANZZAHL */
|
||||
$note = 1;
|
||||
|
||||
/* NEGATIVE GANZZAHL */
|
||||
$negzahl = -2;
|
||||
|
||||
/* KOMMAZAHL */
|
||||
$kommazahl=1.23;
|
||||
|
||||
/* GROßE ZAHL*/
|
||||
$grossezahl = 5.5e6; // 5500000
|
||||
|
||||
/* KLEINE ZAHL*/
|
||||
$kleinzahl = 1.2e-3; // 0.0012
|
||||
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
24
progp/lernen/zusammenfassung_ka1/while-schleifen.php
Normal file
24
progp/lernen/zusammenfassung_ka1/while-schleifen.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
$i=0;
|
||||
|
||||
while ($i < 10) {
|
||||
echo "Diese Schleife durschlief schon ". $i." mal diesen Code!<br>";
|
||||
$i++;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
16
progp/lernen/übung_ka1/raten.html
Normal file
16
progp/lernen/übung_ka1/raten.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Rate die Zahl!</h1>
|
||||
<form action="raten.html">
|
||||
<label for="zahl">Zahl:</label>
|
||||
<input type="number" name="input_zahl" id="zahl">
|
||||
<button type="submit">Raten</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
35
progp/lernen/übung_ka1/raten.php
Normal file
35
progp/lernen/übung_ka1/raten.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Rate die Zahl!</h1>
|
||||
<form action="raten.php">
|
||||
<label for="id_zahl">Zahl:</label>
|
||||
<input type="number" name="name_zahl" id="id_zahl">
|
||||
<button type="submit">Raten</button>
|
||||
</form>
|
||||
<?php
|
||||
$zahl = $_REQUEST['input_zahl'];
|
||||
$random = rand(1, 100);
|
||||
if ($zahl == $random) {
|
||||
echo "<p>Richtig!</p>";
|
||||
if ($zahl % 2 == 0) {
|
||||
echo "<p>Die Zahl ist gerade!</p>";
|
||||
} else {
|
||||
echo "<p>Die Zahl ist ungerade!</p>";
|
||||
}
|
||||
} else {
|
||||
echo "Falsch!";
|
||||
if ($zahl % 2 == 0) {
|
||||
echo "<p>Die Zahl ist gerade!</p>";
|
||||
} else {
|
||||
echo "<p>Die Zahl ist ungerade!</p>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user