Voll Upload SGD Fachinformatiker PHP
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
function flaeche_rechteck(int $laenge, int $breite, string $einheit )
|
||||
{
|
||||
echo "<p>Die Fläsche des Rechtecks beträgt " .($laenge * $breite) ." Quadrat {$einheit}.</p>\n";
|
||||
}
|
||||
|
||||
flaeche_rechteck(5, "2", "meter");
|
||||
flaeche_rechteck(351, 212, "millimeter");
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Formular Auswerten</title>
|
||||
<?php
|
||||
require("meinefunktionen.inc.php")
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
$zahl1 = $_POST["zahl1"];
|
||||
$zahl2 = $_POST["zahl2"];
|
||||
|
||||
$ergebnis = addiere($zahl1, $zahl2);
|
||||
|
||||
echo "<p>Die Summe aus $zahl1 + $zahl2 beträgt $ergebnis!</p>\n";
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
$zahl = 15;
|
||||
|
||||
if ($zahl >= 10)
|
||||
{
|
||||
function quadrat($qzahl)
|
||||
{
|
||||
echo "Das Qadrat von $qzahl ist "
|
||||
.($qzahl * $qzahl) .".\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
quadrat($zahl);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
if (!empty($_POST)) {
|
||||
print_r($_POST); // Auswertung der Checkboxen
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<form method="post">
|
||||
<ul>
|
||||
<li>
|
||||
<input type="checkbox" name="CBox1" id="cb1" value="Checkbox 1">
|
||||
<label for="cb1">Checkbox Nr.1</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="CBox2" id="cb2" value="Checkbox 2">
|
||||
<label for="cb1">Checkbox Nr.2</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="CBox3" id="cb3" value="Checkbox 3">
|
||||
<label for="cb1">Checkbox Nr.3</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="CBox4" id="cb4" value="Checkbox 4">
|
||||
<label for="cb1">Checkbox Nr.4</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="CBox5" id="cb5" value="Checkbox 5">
|
||||
<label for="cb1">Checkbox Nr.5</label>
|
||||
</li>
|
||||
</ul>
|
||||
<input type="submit" value="abschicken">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
if (!empty($_POST)) {
|
||||
print_r($_POST); // Auswertung der Checkboxen
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<form method="post">
|
||||
<ul>
|
||||
<li>
|
||||
<input type="checkbox" name="CBoxGrp[]" id="cb1" value="Checkbox 1">
|
||||
<label for="cb1">Checkbox Nr.1</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="CBoxGrp[]" id="cb2" value="Checkbox 2">
|
||||
<label for="cb1">Checkbox Nr.2</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="CBoxGrp[]" id="cb3" value="Checkbox 3">
|
||||
<label for="cb1">Checkbox Nr.3</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="CBoxGrp[]" id="cb4" value="Checkbox 4">
|
||||
<label for="cb1">Checkbox Nr.4</label>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" name="CBoxGrp[]" id="cb5" value="Checkbox 5">
|
||||
<label for="cb1">Checkbox Nr.5</label>
|
||||
</li>
|
||||
</ul>
|
||||
<input type="submit" value="abschicken">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,58 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Sicherheit</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if (isset($_POST["kName"])) {
|
||||
|
||||
echo <<<AUSGABE
|
||||
<p>Ihre Eingaben: </p>
|
||||
<ul>
|
||||
<li>Name: {$_POST["kName"]}</li>
|
||||
<li>E-Mail: {$_POST["kMail"]}</li>
|
||||
</ul>
|
||||
<p>Ihre Nachricht: <br>
|
||||
{$_POST["kNachricht"]}</p>
|
||||
AUSGABE;
|
||||
}
|
||||
|
||||
?>
|
||||
<h1>Kontakt</h1>
|
||||
|
||||
<form method="post">
|
||||
<p>Bitte geben Sie Ihre Kontaktdaten und Ihre Nachricht
|
||||
ein.</p>
|
||||
<p><label for="kName">Name: </label><br>
|
||||
<input type="text"
|
||||
id = "kName"
|
||||
name = "kName"
|
||||
size="25"
|
||||
required
|
||||
placeholder="Bitte geben Sie Ihren Namen ein."
|
||||
autofocus>
|
||||
</p>
|
||||
<p><label for="kMail">E-Mail: </label><br>
|
||||
<input type="email"
|
||||
id = "kMail"
|
||||
name = "kMail"
|
||||
size="25"
|
||||
required
|
||||
placeholder="Bitte geben Sie Ihre E-Mailadresse ein."
|
||||
>
|
||||
</p>
|
||||
<p><label for="kNachricht">Ihre Nachricht: </label><br>
|
||||
<textarea
|
||||
id = "kNachricht"
|
||||
name = "kNachricht"
|
||||
required
|
||||
placeholder="Bitte geben Sie hier Ihre Nachricht ein."
|
||||
rows="10"
|
||||
></textarea>
|
||||
</p>
|
||||
<p><input type = "submit" value="Senden"></p>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
|
||||
.sign {
|
||||
width: 250px;
|
||||
border-top-style: dashed;
|
||||
border-width: 3px;
|
||||
font-family: arial, lucida console, sans-serif;
|
||||
font-size: 12pt;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<title>Funktionen</title>
|
||||
<?php
|
||||
|
||||
function signatur () //Funktionsdefinition
|
||||
{
|
||||
$name = "Christopher Münzer";
|
||||
$strasse = "Bromberger Strasse 21";
|
||||
$plz = "46145";
|
||||
$ort = "Oberhausen";
|
||||
|
||||
echo "<div class='sign'>\n";
|
||||
echo "<p>$name<br>\n";
|
||||
echo "$strasse<br>\n";
|
||||
echo "$plz $ort</p>\n";
|
||||
echo "</div>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
signatur(); //Funktionsaufruf
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>Dateien einbinden</title>
|
||||
|
||||
<?php
|
||||
|
||||
//include("meinefunktionen.inc.php");
|
||||
require("meinefunktionen.inc.php");
|
||||
|
||||
?>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
$ergebnis = addiere(5, 21);
|
||||
|
||||
echo $ergebnis;
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
$ergebnis = subtrahiere($ergebnis, 14);
|
||||
|
||||
echo $ergebnis;
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
$ergebnis = multipliziere($ergebnis, 6);
|
||||
|
||||
echo $ergebnis;
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
$ergebnis = dividiere($ergebnis, 3);
|
||||
|
||||
echo $ergebnis;
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Einsendeaufgabe 1</title>
|
||||
<?php
|
||||
require("dynauswahl.php")
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post">
|
||||
<p>
|
||||
<?php echo dynAuswahl("dynamisch1", "auswahl1", array("Brot", "Butter", "Milch", "Eier", "Käse", "wurst"), false) ?>
|
||||
</p>
|
||||
<p>
|
||||
<?php echo dynAuswahl("dynamisch2", "auswahl2", array("Schrauben", "Nägel", "Haken", "Nadeln", "Dübel"), true); ?>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Abschicken">
|
||||
</p>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,81 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Einsendeaufgabe 2</title>
|
||||
<?php
|
||||
require("meinefunktionen.inc.php");
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Rechner</h1>
|
||||
<?php
|
||||
if(is_numeric($_POST["zahl1"]) && is_numeric($_POST["zahl2"])) {
|
||||
|
||||
if(isset($_POST["zahl1"])){
|
||||
|
||||
switch($_POST["operator"]){
|
||||
case "+":
|
||||
$ergebnis = addiere($_POST["zahl1"], $_POST["zahl2"]);
|
||||
break;
|
||||
case "-":
|
||||
$ergebnis = subtrahiere($_POST["zahl1"], $_POST["zahl2"]);
|
||||
break;
|
||||
case "*":
|
||||
$ergebnis = multipliziere($_POST["zahl1"], $_POST["zahl2"]);
|
||||
break;
|
||||
case "/":
|
||||
$ergebnis = dividiere($_POST["zahl1"], $_POST["zahl2"]);
|
||||
break;
|
||||
default:
|
||||
echo "<p><b>Bitte eine Rechenoperation angeben!</b></p>\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(isset($_POST["zahl1"])){
|
||||
echo "Bitte Nummern eingeben";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if(isset($ergebnis)){
|
||||
echo "<p><b> {$_POST["zahl1"]} {$_POST["operator"]} {$_POST["zahl2"]} = $ergebnis</b></p>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
|
||||
<p>
|
||||
Bitte geben Sie in den Feldern die Daten ein:
|
||||
</p>
|
||||
<p>
|
||||
<label for="zahl1">Zahl 1</label>
|
||||
<input type="text" name="zahl1" id="zahl1" placeholder="Zahl 1" required autofocus>
|
||||
</p>
|
||||
<p>
|
||||
<label for="zahl2">Zahl 2</label>
|
||||
<input type="text" name="zahl2" id="zahl2" placeholder="Zahl 2" required>
|
||||
</p>
|
||||
<p>
|
||||
<li><input type="radio" name="operator" id="addieren" value="+">
|
||||
<label for="addieren">+</label></li>
|
||||
<li><input type="radio" name="operator" id="subtrahieren" value="-">
|
||||
<label for="subtrahieren">-</label></li>
|
||||
<li><input type="radio" name="operator" id="multiplikation" value="*">
|
||||
<label for="multiplikation">*</label></li>
|
||||
<li><input type="radio" name="operator" id="division" value="/">
|
||||
<label for="division">/</label></li>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Berechnen">
|
||||
<input type="reset" value="Zurücksetzen">
|
||||
</p>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Einsendeaufgabe 4</title>
|
||||
<?php
|
||||
require("berechnung.php");
|
||||
require("setopt.php");
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Grundstückspreise</h1>
|
||||
<?php berechnung() ?>
|
||||
<fieldset>
|
||||
<form method="post">
|
||||
<p>
|
||||
<label for="breite">Breite:</label>
|
||||
<input type="text" name="breite" id="breite" placeholder="Breite?" required autofocus value="<?= htmlspecialchars($_POST['breite']) ?? '' ?>">
|
||||
</p>
|
||||
<p>
|
||||
<label for="zahl2">Länge:</label>
|
||||
<input type="text" name="laenge" id="laenge" placeholder="Länge?" required value="<?= htmlspecialchars($_POST['laenge']) ?? '' ?>">
|
||||
</p>
|
||||
<p>
|
||||
<label for="pqm">Preis pro m²:</label>
|
||||
<input type="text" name="pqm" id="pqm" placeholder="Preis / m²?" required value="<?= htmlspecialchars($_POST['pqm']) ?? '' ?>">
|
||||
</p>
|
||||
<p>
|
||||
<label for="provision">Provisionssatz:</label>
|
||||
<select name="provision" id="provision">
|
||||
<?php setOption("0.03", "3");?>
|
||||
<?php setOption("0.04", "4");?>
|
||||
<?php setOption("0.05", "5");?>
|
||||
<?php setOption("0.06", "6");?>
|
||||
<?php setOption("0.07", "7");?>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="mws">Mehrwertsteuer</label>
|
||||
<input type="checkbox" name="mws" id="mws" value="0.19" <?= ($_POST['mws'] ?? '') == '0.19' ? 'checked' : '' ?>>
|
||||
</p>
|
||||
</fieldset>
|
||||
<p>
|
||||
<input type="submit" value="Berechnen">
|
||||
</p>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
require("meinefunktionen.inc.php");
|
||||
|
||||
function berechnung() {
|
||||
if(isset($_POST["breite"])) {
|
||||
if (is_numeric($_POST["breite"]) && is_numeric($_POST["laenge"]) && is_numeric($_POST["pqm"])){
|
||||
|
||||
$qm = multipliziere($_POST["breite"],$_POST["laenge"]);
|
||||
$np = multipliziere($qm ,$_POST["pqm"]);
|
||||
$prov = multipliziere($np, $_POST["provision"]);breite:
|
||||
$nprov = addiere($np, $prov);
|
||||
|
||||
echo "\n\t<p>Breite: {$_POST["breite"]}m";
|
||||
echo "\n\t<br>Länge: {$_POST["laenge"]}m";
|
||||
echo "\n\t<br>Preis pro qm: {$_POST["pqm"]}€";
|
||||
echo "\n\t<br>Nettopreis: $np €";
|
||||
echo "\n\t<br>Nettopreis mit Provision: $nprov €";
|
||||
|
||||
if (isset($_POST["mws"])) {
|
||||
$bmws = multipliziere($nprov, $_POST["mws"]);
|
||||
$brutto = addiere($nprov, $bmws);
|
||||
echo "\n\t<br>Bruttopreis: $brutto €</p>";
|
||||
}
|
||||
else {
|
||||
echo "</p>";
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
echo "Bitte Zahlen eingeben";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
function dynAuswahl (string $id, string $name, array $options, bool $multiple) {
|
||||
|
||||
if ($multiple == 1) {
|
||||
|
||||
$multiple ="multiple";
|
||||
}
|
||||
|
||||
switch($id){
|
||||
|
||||
case "dynamisch1":
|
||||
echo"<select id='$id' name='$name' $multiple><br>";
|
||||
foreach($options as $wert){
|
||||
echo "\n\t\t\t\t\t<option value='$wert'>$wert</option><br>";
|
||||
}
|
||||
echo "\n\t\t\t\t</select>";
|
||||
break;
|
||||
|
||||
case "dynamisch2":
|
||||
echo"<select id='$id' name='$name' $multiple><br>";
|
||||
foreach($options as $wert){
|
||||
echo "\n\t\t\t\t\t<option value='$wert'>$wert</option><br>";
|
||||
}
|
||||
echo "\n\t\t\t\t</select>";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
function addiere($summand1, $summand2){
|
||||
return ($summand1 + $summand2);
|
||||
}
|
||||
|
||||
function subtrahiere($minuend, $subtrahend) {
|
||||
return ($minuend - $subtrahend);
|
||||
}
|
||||
|
||||
function multipliziere($faktor1, $faktor2) {
|
||||
|
||||
return ($faktor1 * $faktor2);
|
||||
|
||||
}
|
||||
|
||||
function dividiere($dividend, $divisor) {
|
||||
|
||||
if ($divisor != 0) {
|
||||
|
||||
return ($dividend / $divisor);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
function setOption ($wert, $text){
|
||||
$ausgabe = "<option value='{$wert}'";
|
||||
|
||||
if (isset($_POST["breite"])) {
|
||||
if ($_POST["provision"] == $wert) {
|
||||
$ausgabe .= " selected";
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($text)) {
|
||||
$text = $wert;
|
||||
}
|
||||
$ausgabe .= ">$text</option>\n";
|
||||
echo $ausgabe;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Formular und Auswertung</title>
|
||||
<?php
|
||||
require("meinefunktionen.inc.php")
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if(isset($_POST["zahl1"])){ //hier wird geprüft ob das Fomular schonmal ausgeführt wurde.
|
||||
$zahl1 = $_POST["zahl1"];
|
||||
$zahl2 = $_POST["zahl2"];
|
||||
$ergebnis = addiere($zahl1, $zahl2);
|
||||
echo "<p>Die Summe aus $zahl1 + $zahl2 beträgt $ergebnis!</p>\n";
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <!-- mit ?php echo $_SERVER["PHP_SELF"]; ?> wird der eigene dateipfadund bezeichnung ausgegeben -->
|
||||
<p>
|
||||
Bitte geben Sie die beiden Zahlen in die Felder ein, die Sie addieren möchten.
|
||||
</p>
|
||||
<p>
|
||||
<label for="zahl1">Zahl 1</label>
|
||||
<input type="text" name="zahl1" id="zahl1" placeholder="Zahl 1" required autofocus>
|
||||
</p>
|
||||
<p>
|
||||
<label for="zahl2">Zahl 2</label>
|
||||
<input type="text" name="zahl2" id="zahl2" placeholder="Zahl 2" required>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Addieren">
|
||||
<input type="reset" value="Reset">
|
||||
</p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Formular und Auswertung</title>
|
||||
<?php
|
||||
require("meinefunktionen.inc.php")
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if(isset($_POST["zahl1"])){ //hier wird geprüft ob das Fomular schonmal ausgeführt wurde.
|
||||
$zahl1 = $_POST["zahl1"];
|
||||
$zahl2 = $_POST["zahl2"];
|
||||
$ergebnis = addiere($zahl1, $zahl2);
|
||||
echo "<p>Die Summe aus $zahl1 + $zahl2 beträgt $ergebnis!</p>\n";
|
||||
}
|
||||
?>
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <!-- mit ?php echo $_SERVER["PHP_SELF"]; ?> wird der eigene dateipfadund bezeichnung ausgegeben -->
|
||||
<p>
|
||||
Bitte geben Sie die beiden Zahlen in die Felder ein, die Sie addieren möchten.
|
||||
</p>
|
||||
<p>
|
||||
<label for="zahl1">Zahl 1</label>
|
||||
<input type="text" name="zahl1" id="zahl1" placeholder="Zahl 1" required autofocus>
|
||||
</p>
|
||||
<p>
|
||||
<label for="zahl2">Zahl 2</label>
|
||||
<input type="text" name="zahl2" id="zahl2" placeholder="Zahl 2" required>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Addieren">
|
||||
<input type="reset" value="Reset">
|
||||
</p>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Formulare</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="addieren.php" method="post">
|
||||
<p>Bitte geben Sie die beiden Zahlen in die Felder ein, die Sie addieren möchten.</p>
|
||||
<p>
|
||||
<label for="zahl1">Zahl 1</label>
|
||||
<input type="text" name="zahl1" id="zahl1" placeholder="Zahl 1" required autofocus>
|
||||
</p>
|
||||
<p>
|
||||
<label for="zahl2">Zahl 2</label>
|
||||
<input type="text" name="zahl2" id="zahl2" placeholder="Zahl 2" required>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Addiere">
|
||||
<input type="reset">
|
||||
</p>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
function auswertung(){
|
||||
if ($_POST["vSpeise"] == ""
|
||||
&& $_POST["hSpeise"] == ""
|
||||
&& $_POST["nSpeise"] == ""
|
||||
&& $_POST["getraenk"] == "") {
|
||||
echo "<p> Sie haben nichts ausgewählt. Bitte wählen Sie";
|
||||
}
|
||||
else {
|
||||
echo "<h3>Vielen Dank für Ihre Bestellung.</h3>";
|
||||
echo "<p> Sie wählten:</p>\n";
|
||||
echo "<ul>\n";
|
||||
|
||||
if($_POST["vSpeise"] != "") {
|
||||
echo "<li>Vorspeise: {$_POST['vSpeise']}</li>";
|
||||
}
|
||||
|
||||
if($_POST["hSpeise"] != "") {
|
||||
echo "<li>Hauptspeise: {$_POST['hSpeise']}</li>";
|
||||
}
|
||||
|
||||
if($_POST["nSpeise"] != "") {
|
||||
echo "<li>Dessert: {$_POST['nSpeise']}</li>";
|
||||
}
|
||||
if($_POST["getraenk"] != "") {
|
||||
echo "<li>Getränk: {$_POST['getraenk']}</li>";
|
||||
}
|
||||
echo "</ul>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if (isset($_POST["vSpeise"])) {
|
||||
$gaststatus = $_POST["gastStatus"];
|
||||
}
|
||||
else {
|
||||
$gaststatus = "";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
function flaeche_rechteck($laenge, $breite, $einheit = "meter")
|
||||
{
|
||||
echo "<p>Die Fläsche des Rechtecks beträgt " .($laenge * $breite) ." Quadrat {$einheit}.</p>\n";
|
||||
}
|
||||
|
||||
flaeche_rechteck(5, 2);
|
||||
flaeche_rechteck(351, 212, "millimeter");
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
function summiere(){
|
||||
$sumanden = func_get_args();
|
||||
$summe = 0;
|
||||
|
||||
if(is_array($sumanden)) {
|
||||
foreach($sumanden as $wert) {
|
||||
$summe += $wert;
|
||||
}
|
||||
}
|
||||
echo "<p>$summe</p>";
|
||||
}
|
||||
|
||||
|
||||
summiere(1,5,7,2,4,2,5,6,4,9,7,5);
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
function aussen()
|
||||
{
|
||||
|
||||
echo "Ich bin die Funktion aussen()";
|
||||
|
||||
function innen()
|
||||
{
|
||||
|
||||
echo "Ich bin die Funktion innen()";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
aussen();
|
||||
innen();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
function summiere(){
|
||||
$summe = 0;
|
||||
|
||||
for($i = 0; $i < func_num_args(); $i++){
|
||||
$summe += func_get_arg($i);
|
||||
|
||||
}
|
||||
echo "<p>$summe</p>\n";
|
||||
}
|
||||
|
||||
summiere(1,5,7,2,4,2,5,6,4,9,7,5);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
// 2.4.1.2
|
||||
|
||||
function setOption ($gang, $wert, $text){
|
||||
$ausgabe = "<option value='{$wert}'";
|
||||
|
||||
if (isset($_POST["vSpeise"])) {
|
||||
if ($_POST[$gang] == $wert) {
|
||||
$ausgabe .= " selected";
|
||||
}
|
||||
}
|
||||
|
||||
// Wenn Kein Text übergeben wird, dann soll der Text mit dem Wert identisch sein
|
||||
|
||||
if(empty($text)) {
|
||||
$text = $wert;
|
||||
}
|
||||
$ausgabe .= ">$text</option>\n";
|
||||
echo $ausgabe;
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
function summiere($zahlen) {
|
||||
$summe = 0;
|
||||
|
||||
foreach($zahlen as $wert) {
|
||||
$summe += $wert;
|
||||
|
||||
if($summe > 50) {
|
||||
echo "grenze erreicht";
|
||||
return $summe;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo "Das wird nur Ausgegeben wenn die Summe <= 50 ist";
|
||||
return $summe;
|
||||
}
|
||||
|
||||
$summe = summiere(array(1,5,7,2,4,2,5,6,4,9,7,5));
|
||||
echo "<p>$summe</p>\n";
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
$summe = summiere(array(1,2,5,6,4,9,7,5));
|
||||
echo "<p>$summe</p>\n";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
function summiere(... $summanden){
|
||||
global $summe;
|
||||
|
||||
foreach($summanden as $wert){
|
||||
$summe += $wert;
|
||||
}
|
||||
}
|
||||
$summe = 0;
|
||||
|
||||
summiere(1,5,7,2,4,2,5,6,4,9,7,5);
|
||||
|
||||
|
||||
echo "<p>$summe</p>\n";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
function summiere (... $summanden){
|
||||
foreach($summanden as $wert){
|
||||
// $summe += $wert;
|
||||
}
|
||||
}
|
||||
|
||||
$summe = 0;
|
||||
|
||||
summiere(1,5,7,2,4,2,5,6,4,9,7,5);
|
||||
|
||||
echo "<p>$summe</p>\n";
|
||||
?>
|
||||
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Kantinenbestellung</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
<h2>Menüauswahl</h2>
|
||||
<p>
|
||||
<label for="vSpeise">Vorspeise:</label>
|
||||
<select name="vSpeise" id="vSpeise">
|
||||
<option value="salat">Gemischter Salat</option>
|
||||
<option value="rinterbouillon">Rinderbouillon</option>
|
||||
<option value="schafskaese">Gebackener Schafskäse</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="hSpeise">Haupgericht:</label>
|
||||
<select name="hSpeise" id="hSpeise">
|
||||
<option value="pizza">Pizza</option>
|
||||
<option value="schnitzel">Schnitzel mit Pommes</option>
|
||||
<option value="risotto">Basilikum-Risotto mit Spargel</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="getraenk">Getränkt:</label>
|
||||
<select name="getraenkt" id="getraenkt">
|
||||
<option value="schorle">Apfelschorle</option>
|
||||
<option value="cola">Coca Cola</option>
|
||||
<option value="saft">Fruchtsaft</option>
|
||||
<option value="kaffee">Kaffee</option>
|
||||
<option value="wasser">Mineralwasser</option>
|
||||
<option value="tee">Tee</option>
|
||||
</select>
|
||||
</p>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<p>
|
||||
<input type="radio" name="gastStatus" id="eigener" value="mitarbeiter" checked>
|
||||
<label for="eigener">Mitarbeiter</label><br>
|
||||
<input type="radio" name="gastStatus" id="fremd" value="gast">
|
||||
<label for="fremd">Gast</label>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="bestellen">
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,79 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Kantinenbestellung</title>
|
||||
<?php
|
||||
require("funktion_setopt.php")
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
if(isset($_POST["vSpeise"])){
|
||||
$vSpeise = $_POST["vSpeise"];
|
||||
$hSpeise = $_POST["hSpeise"];
|
||||
$nSpeise = $_POST["nSpeise"];
|
||||
$getraenk = $_POST["getraenk"];
|
||||
$gastStatus= $_POST["gastStatus"];
|
||||
}
|
||||
else {
|
||||
$vSpeise = "";
|
||||
$hSpeise = "";
|
||||
$nSpeise = "";
|
||||
$getraenk = "";
|
||||
$gastStatus= "";
|
||||
}
|
||||
?>
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
<h2>Menüauswahl</h2>
|
||||
<p>
|
||||
<label for="vSpeise">Vorspeise:</label>
|
||||
<select name="vSpeise" id="vSpeise">
|
||||
<option value="salat"<?php if($vSpeise == "salat") {echo "selected";}?>>Gemischter Salat</option>
|
||||
<option value="rinterbouillon"<?php if($vSpeise == "rinterbouillon") {echo "selected";}?>>Rinderbouillon</option>
|
||||
<option value="schafskaese"<?php if($vSpeise == "schafskaese") {echo "selected";}?>>Gebackener Schafskäse</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="hSpeise">Haupgericht:</label>
|
||||
<select name="hSpeise" id="hSpeise">
|
||||
<option value="pizza"<?php if($hSpeise == "pizza") {echo "selected";}?>>Pizza</option>
|
||||
<option value="schnitzel"<?php if($hSpeise == "schnitzel") {echo "selected";}?>>Schnitzel mit Pommes</option>
|
||||
<option value="risotto"<?php if($hSpeise == "risotto") {echo "selected";}?>>Basilikum-Risotto mit Spargel</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="nSpeise">Dessert:</label>
|
||||
<select name="nSpeise" id="nSpeise">
|
||||
<option value="pudding"<?php if($nSpeise == "pudding") {echo "selected";}?>>Pudding</option>
|
||||
<option value="kuchen"<?php if($nSpeise == "kuchen") {echo "selected";}?>>Kuchen</option>
|
||||
<option value="quark"<?php if($nSpeise == "quark") {echo "selected";}?>>Quark mit Obst</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="getraenk">Getränkt:</label>
|
||||
<select name="getraenk" id="getraenk">
|
||||
<option value="schorle"<?php if($getraenk == "schorle") {echo "selected";}?>>Apfelschorle</option>
|
||||
<option value="cola"<?php if($getraenk == "cola") {echo "selected";}?>>Coca Cola</option>
|
||||
<option value="saft"<?php if($getraenk == "saft") {echo "selected";}?>>Fruchtsaft</option>
|
||||
<option value="kaffee"<?php if($getraenk == "kaffee") {echo "selected";}?>>Kaffee</option>
|
||||
<option value="wasser"<?php if($getraenk == "Wasser") {echo "selected";}?>>Mineralwasser</option>
|
||||
<option value="tee"<?php if($getraenk == "tee") {echo "selected";}?>>Tee</option>
|
||||
</select>
|
||||
</p>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<p>
|
||||
<input type="radio" name="gastStatus" id="eigener" value="mitarbeiter" <?php if($gastStatus != "gast") {echo "checked";} ?>>
|
||||
<label for="eigener">Mitarbeiter</label><br>
|
||||
<input type="radio" name="gastStatus" id="fremd" value="gast"<?php if($gastStatus == "gast") {echo "checked";} ?>>
|
||||
<label for="fremd">Gast</label>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="bestellen">
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,71 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>Kantinenbestellung</title>
|
||||
<?php
|
||||
require("funktion_setopt.php");
|
||||
include("funktion_auswertung.php");
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<form action="" method="post">
|
||||
<fieldset>
|
||||
<h2>Menüauswahl</h2>
|
||||
<p>
|
||||
<label for="vSpeise">Vorspeise:</label>
|
||||
<select name="vSpeise" id="vSpeise">
|
||||
<?php setOption("vSpeise", "salat", "Gemischter Salat");?>
|
||||
<?php setOption("vSpeise", "rinterbouillon", "Rinderbouillon");?>
|
||||
<?php setOption("vSpeise", "schafskaese", "Gebackener Schafskäse");?>
|
||||
<?php setOption("vSpeise", "", "Keine Vorspeise!");?>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="hSpeise">Haupgericht:</label>
|
||||
<select name="hSpeise" id="hSpeise">
|
||||
<?php setOption("hSpeise", "pizza", "Pizza");?>
|
||||
<?php setOption("hSpeise", "schnitzel", "Schnitzel mit Pommes Frites");?>
|
||||
<?php setOption("hSpeise", "risotto", "Basilikum-Risotto mit Spargel");?>
|
||||
<?php setOption("hSpeise", "", "Keine Hauptspeise!");?>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="nSpeise">Dessert</label>
|
||||
<select name="nSpeise" id="nSpeise">
|
||||
<?php setOption("nSpeise", "pudding", "Pudding");?>
|
||||
<?php setOption("nSpeise", "kuchen", "Kuchen");?>
|
||||
<?php setOption("nSpeise", "quark", "Quark mit Obst");?>
|
||||
<?php setOption("nSpeise", "", "Kein Dessert!");?>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="getraenk">Getränkt:</label>
|
||||
<select name="getraenk" id="getraenk">
|
||||
<?php setOption("getraenk", "schorle", "Apfelschorle");?>
|
||||
<?php setOption("getraenk", "cola", "Coca Cola");?>
|
||||
<?php setOption("getraenk", "saft", "Fruchtsaft");?>
|
||||
<?php setOption("getraenk", "kaffee", "Kaffee");?>
|
||||
<?php setOption("getraenk", "wasser", "Mineralwasser");?>
|
||||
<?php setOption("getraenk", "tee", "Tee");?>
|
||||
<?php setOption("getraenk", "", "Kein Getränk!");?>
|
||||
</select>
|
||||
</p>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<p>
|
||||
<input type="radio" name="gastStatus" id="eigener" value="mitarbeiter" <?php if($gastStatus != "gast") {echo "checked";} ?>>
|
||||
<label for="eigener">Mitarbeiter</label><br>
|
||||
<input type="radio" name="gastStatus" id="fremd" value="gast"<?php if($gastStatus == "gast") {echo "checked";} ?>>
|
||||
<label for="fremd">Gast</label>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="bestellen">
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
<?php
|
||||
auswertung()
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
if(! empty($_POST)){
|
||||
print_r($_POST);
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<form method="post">
|
||||
<p>
|
||||
<label for="mehrfach">Wählen Sie Ihre(n) Lieblingsmonat:</label>
|
||||
<br>
|
||||
<select name="mAuswahl[]" id="mehrfach" size="12" multiple>
|
||||
<option value="1">Januar</option>
|
||||
<option value="2">Februar</option>
|
||||
<option value="3">März</option>
|
||||
<option value="4">April</option>
|
||||
<option value="5">Mai</option>
|
||||
<option value="6">Juni</option>
|
||||
<option value="7">Juli</option>
|
||||
<option value="8">August</option>
|
||||
<option value="9">September</option>
|
||||
<option value="10">Oktober</option>
|
||||
<option value="11">November</option>
|
||||
<option value="12">Dezember</option>
|
||||
</select>
|
||||
</p>
|
||||
<input type="submit" value="Abschicken">
|
||||
</form>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
function addiere($summand1, $summand2){
|
||||
return ($summand1 + $summand2);
|
||||
}
|
||||
|
||||
function subtrahiere($minuend, $subtrahend) {
|
||||
return ($minuend - $subtrahend);
|
||||
}
|
||||
|
||||
function multipliziere($faktor1, $faktor2) {
|
||||
|
||||
return ($faktor1 * $faktor2);
|
||||
|
||||
}
|
||||
|
||||
function dividiere($dividend, $divisor) {
|
||||
|
||||
if ($divisor != 0) {
|
||||
|
||||
return ($dividend / $divisor);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
function summiere($zahlen){
|
||||
$summe = 0;
|
||||
foreach($zahlen as $wert) {
|
||||
$summe += $wert;
|
||||
}
|
||||
return $summe;
|
||||
}
|
||||
|
||||
$summe = summiere(array(1,5,7,2,4,2,5,6,4,9,7,5));
|
||||
|
||||
echo "<p>$summe</p>\n";
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Sicherheit</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
if(isset($_POST["kName"])) {
|
||||
$kName= htmlspecialchars($_POST["kName"]);
|
||||
$kMail = htmlspecialchars($_POST["kMail"]);
|
||||
$kNachricht = htmlspecialchars($_POST["kNachricht"]);
|
||||
|
||||
|
||||
echo <<<AUSGABE
|
||||
<p>Ihre Eingabe:</p>
|
||||
<ul>
|
||||
<li>Name: {$kName}</li>
|
||||
<li>E-Mail: {$kMail}</li>
|
||||
</ul>
|
||||
|
||||
<p>Ihre Nachricht: <br>
|
||||
{$kNachricht}</p>\n
|
||||
|
||||
AUSGABE;
|
||||
}
|
||||
?>
|
||||
|
||||
<h1>Kontakt</h1>
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
|
||||
<p>
|
||||
Bitte geben Sie Ihre Kontaktdaten und Ihre Nachricht ein.
|
||||
</p>
|
||||
<p>
|
||||
<label for="kName">Name:</label>
|
||||
<input type="text" id="kName" name="kName" size="25" required placeholder="Bitte geben Sie Ihren Namen ein." autofocus>
|
||||
</p>
|
||||
<p>
|
||||
<label for="kMail">E-Mail:</label>
|
||||
<input type="mail" name="kMail" id="kMail" size="25" required placeholder="Bitte geben Sie Ihre E-Mailadresse ein.">
|
||||
</p>
|
||||
<p>
|
||||
<label for="kNachricht">Ihre Nachricht:</label><br>
|
||||
<textarea name="kNachricht" id="kNachricht" required placeholder="Bitte geben Sie Ihre Nachricht ein." rows="10"></textarea>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" value="Senden">
|
||||
</p>
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1); //führt zu einer strengen Typisierung der Variablen
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Eigene Funktionen</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<?php
|
||||
|
||||
function flaeche_rechteck(int $laenge, int $breite, string $einheit )
|
||||
{
|
||||
echo "<p>Die Fläsche des Rechtecks beträgt " .($laenge * $breite) ." Quadrat {$einheit}.</p>\n";
|
||||
}
|
||||
|
||||
flaeche_rechteck(5, 2, "meter");
|
||||
flaeche_rechteck(351, 212, "millimeter");
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
function summiere (... $summanden){
|
||||
foreach($summanden as $wert){
|
||||
$GLOBALS['summe'] += $wert;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$summe = 0;
|
||||
|
||||
summiere(1,5,7,2,4,2,5,6,4,9,7,5);
|
||||
|
||||
echo "<p>$summe</p>\n";
|
||||
?>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
function summiere(){
|
||||
$index = func_num_args();
|
||||
|
||||
echo "$index";
|
||||
}
|
||||
|
||||
|
||||
summiere(1,5,7,2,4,2,5,6,4,9,7,5);
|
||||
?>
|
||||
@@ -0,0 +1,85 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>TestFormular</title>
|
||||
<?php
|
||||
require("meinefunktionen.inc.php");
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
<center>
|
||||
<h1> Rechenmaschiene</h1>
|
||||
<?php
|
||||
if(is_numeric($_POST["zahl1"]) && is_numeric($_POST["zahl2"])) {
|
||||
|
||||
if(isset($_POST["zahl1"])){
|
||||
|
||||
switch($_POST["faktor"]){
|
||||
case "+":
|
||||
$ergebnis = addiere($_POST["zahl1"], $_POST["zahl2"]);
|
||||
break;
|
||||
case "-":
|
||||
$ergebnis = subtrahiere($_POST["zahl1"], $_POST["zahl2"]);
|
||||
break;
|
||||
case "*":
|
||||
$ergebnis = multipliziere($_POST["zahl1"], $_POST["zahl2"]);
|
||||
break;
|
||||
case "/":
|
||||
$ergebnis = dividiere($_POST["zahl1"], $_POST["zahl2"]);
|
||||
break;
|
||||
default:
|
||||
echo "<p><b>Bitte eine richtige Rechenoperation angeben!</b></p>\n";
|
||||
break;
|
||||
}
|
||||
///echo "<p>Das Ergebnis von $zahl1 $faktor $zahl2 ist $ergebnis</p>\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(isset($_POST["zahl1"])){
|
||||
echo "Bitte Nummern eingeben";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
|
||||
<p>
|
||||
Bitte geben Sie in den Feldern die Daten ein:
|
||||
</p>
|
||||
<p>
|
||||
<label for="zahl1">Zahl 1</label>
|
||||
<input type="text" name="zahl1" id="zahl1" placeholder="Zahl 1" required autofocus>
|
||||
</p>
|
||||
<p>
|
||||
<label for="zahl2">Zahl 2</label>
|
||||
<input type="text" name="zahl2" id="zahl2" placeholder="Zahl 2" required>
|
||||
</p>
|
||||
<p>
|
||||
<li><input type="radio" name="faktor" id="addieren" value="+" constant>
|
||||
<label for="addieren">+</label></li>
|
||||
<li><input type="radio" name="faktor" id="subtrahieren" value="-">
|
||||
<label for="subtrahieren">-</label></li>
|
||||
<li><input type="radio" name="faktor" id="multiplikation" value="*">
|
||||
<label for="multiplikation">*</label></li>
|
||||
<li><input type="radio" name="faktor" id="division" value="/">
|
||||
<label for="division">/</label></li>
|
||||
</p>
|
||||
|
||||
<!--<p>
|
||||
<label for="faktor">Faktor</label>
|
||||
<input type="text" name="faktor" id="faktor" placeholder="+ - * /" required>
|
||||
</p> -->
|
||||
<p>
|
||||
<input type="submit" value="Berechnen">
|
||||
<input type="reset" value="Zurücksetzen">
|
||||
</p>
|
||||
|
||||
</form>
|
||||
<?php
|
||||
if(isset($ergebnis/*$_POST["zahl1"]*/)){
|
||||
echo "<p>Das Ergebnis von {$_POST["zahl1"]} {$_POST["faktor"]} {$_POST["zahl2"]} ist $ergebnis.</p>\n";
|
||||
}
|
||||
//echo "<p> " .$_SERVER["SERVER_ADMIN"] ."</p>\n";
|
||||
?>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
function eineFunktion(&$param)
|
||||
|
||||
{
|
||||
|
||||
$param = $param * 2;
|
||||
|
||||
}
|
||||
|
||||
function nochEineFunktion($param)
|
||||
|
||||
{
|
||||
|
||||
$param = $param / 2;
|
||||
|
||||
}
|
||||
|
||||
$var1 = 10;
|
||||
|
||||
$var2 = 20;
|
||||
|
||||
$var3 = 30;
|
||||
|
||||
$var4 = 0;
|
||||
|
||||
$var4 = &$var1;
|
||||
|
||||
echo "var4: $var4<br>"; // Ausgabe: ______________________ 10
|
||||
|
||||
eineFunktion($var4);
|
||||
|
||||
echo "var1: $var1<br>"; // Ausgabe: ______________________ 20
|
||||
|
||||
if ($var4 > $var2) {
|
||||
|
||||
$var4 = $var2;
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
$var4 = &$var3;
|
||||
|
||||
}
|
||||
|
||||
|
||||
nochEineFunktion($var4);
|
||||
|
||||
echo "var4: $var4<br>"; // Ausgabe: _______________________ 30
|
||||
|
||||
eineFunktion($var3);
|
||||
|
||||
echo "var1: $var1<br>"; // Ausgabe: ________________________ 20
|
||||
|
||||
echo "var2: $var2<br>"; // Ausgabe: ________________________ 20
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
function summiere(... $summanden) {
|
||||
$summe = 0;
|
||||
|
||||
foreach($summanden as $wert) {
|
||||
$summe += $wert;
|
||||
}
|
||||
|
||||
echo "<p>$summe</p>\n";
|
||||
|
||||
}
|
||||
|
||||
summiere(1,5,7,2,4,2,5,6,4,9,7,5);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Eigene Funktionen</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
function summiere (int ... $summanden) {
|
||||
$summe = 0;
|
||||
|
||||
foreach($summanden As $wert) {
|
||||
$summe += $wert;
|
||||
}
|
||||
|
||||
echo "<p>$summe</p>\n";
|
||||
|
||||
}
|
||||
|
||||
summiere(1,5,7,2,4,"2",5,6,4,9,7,5);
|
||||
|
||||
?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
function verdoppler(&$param) {
|
||||
$param = $param * 2;
|
||||
}
|
||||
|
||||
$zahl = 10;
|
||||
|
||||
verdoppler($zahl);
|
||||
|
||||
echo "$zahl";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
function verdoppler($param) {
|
||||
$param = $param * 2;
|
||||
|
||||
}
|
||||
|
||||
$zahl = 10;
|
||||
|
||||
verdoppler($zahl);
|
||||
|
||||
echo "$zahl";
|
||||
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
function summiere($summanden)
|
||||
{
|
||||
$summe = 0;
|
||||
|
||||
if (is_array($summanden))
|
||||
{
|
||||
foreach($summanden as $wert)
|
||||
{
|
||||
$summe += $wert;
|
||||
}
|
||||
}
|
||||
echo "<p>$summe</p>\n";
|
||||
}
|
||||
|
||||
|
||||
summiere(array(1,5,7,2,4,2,5,6,4,9,7,5));
|
||||
summiere([1,5,7,2,4,2,5,6,4,9,7,5]);
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user