Ich habe folgendes Problem, für Informatik soll ich einen Taschenrechner mit den Funktionen des addierens, subtrahierens, multiplizierens und dividierens erstellen. Zusätzlich sollten wir noch eine Währungsumrechner von DM in € und umgekehrt erstellen, im Grunde ist das ja das gleiche wie das vorige - ist aber auch nicht so wichtig.
Nun mein Problem: Das Script läuft an sich und rechnet, nur leider rechnet er immer ohne Nachkommastellen, sprich 12 : 7 = 1 ^^ Das ist natürlich nicht so sonderlich toll. Ich habe es schon irwie mit "number_format" probiert, etc. etc. ^^
Hier ist der Code von dem Taschenrechner:
Letztlich ist vielleicht auch irgendwie das Problem, weswegen ich das nicht hinkriege, dass das Ergebnis ja schließlich (logischerweise) eine Variable ist. Wahrscheinlich bin ich einfach nur dumm, aber das wäre mir auch nichts neues 
Hoffe ihr könnt mir helfen :c
Nun mein Problem: Das Script läuft an sich und rechnet, nur leider rechnet er immer ohne Nachkommastellen, sprich 12 : 7 = 1 ^^ Das ist natürlich nicht so sonderlich toll. Ich habe es schon irwie mit "number_format" probiert, etc. etc. ^^
Hier ist der Code von dem Taschenrechner:
PHP-Code:
<?php
if (!empty($_POST["submit"])) // Wenn Eingabe 'submit' ungleich leer ist, dann mache...
{
$zahl1 = $_POST["zahl1"]; // Variable 'zahl1' = Zahl 1; Variable 'zahl1' = Übertragener Wert von 'name=zahl1'
$zahl2 = $_POST["zahl2"]; // Variable 'zahl2' = Zahl 2; Variable 'zahl2' = Übertragener Wert von 'name=zahl2'
$rz = $_POST["rz"]; // Variable 'rz' = Rechenzeichen; Variable 'rz' = Übertragener Wert von 'rz' (ausgewählte Option)
if ($rz == "+") $e = bcadd($zahl1, $zahl2); // e = Ergebnis; Addition von Variable 'zahl1' und Variable 'zahl2'
if ($rz == "-") $e = bcsub($zahl1, $zahl2); // e = Ergebnis; Subtraktion von Variable 'zahl1' und Variable 'zahl2'
if ($rz == "*") $e = bcmul($zahl1, $zahl2); // e = Ergebnis; Multipliaktion von Variable 'zahl1' und Variable 'zahl2'
if ($rz == ":") $e = bcdiv($zahl1, $zahl2); // e = Ergebnis; Division von Variable 'zahl1' und Variable 'zahl2'
if ($rz == "€") $e = bcmul($zahl1, 1.95583) AND $dm = "DM"; // e = Ergebnis; Multiplikation von Variable 'zahl1' und '1.95583'
if ($rz == "DM") $e = bcdiv($zahl1, 1.95583) AND $euro = "€"; // e = Ergebnis; Division von Variable 'zahl1' und '1.95833'
echo "".$zahl1." ".$rz." ".$zahl2." = ".$e." ".$euro." ".$dm.""; // Ausgabe
}
?>

Hoffe ihr könnt mir helfen :c
Kommentar