Scripthelp.de script the World
Kostenlose Informationen und Beratung zum thema SEO, SEM, Suchmaschinenmarketing, Suchmaschinenoptimierung für ihre Internetseite
Links PHP Scripte Schnipsel Links
Index News PHP Scripte Schnipsel Index

Ergebnisse mit zwei stellen nach dem Komma



<?php
$d=50;
$c=2;
$quotient = $d / $c;
$ergebnis = sprintf("%01.2f", $quotient);
echo "Aufgabe: ".$d." / ".$c."<br>";
echo "Ergebnis: ".$quotient."<br>";
echo "Ergebnis mit 2 Nachkommastellen: ".$ergebnis;
?>

Randomize (Zufallszahlen)



<?php
$zufallszahl = "";
$stellen = 5;
mt_srand ((double)microtime()*1000000);
for ($i=0;$i<$stellen;$i++) {
$zufallszahl .= mt_rand(0, 9);
}
echo $zufallszahl;
?>

Gerade oder Ungerade Zahlen:



<?php
$a=2;
$b=7;
if ($a % 2 != 0) { echo $a." : ungerade Zahl"; }
else { echo $a." : gerade Zahl"; }
echo "<br>";
if ($b % 2 != 0) { echo $b." : ungerade Zahl"; }
else { echo $b." : gerade Zahl"; }
?>

Operatoren



<?php
$d=33;
$c=2;
$summe = $d + $c;
$differenz = $d - $c;
$produkt = $d * $c;
$quotient = $d / $c;
echo "Addition: ".$d." + ".$c." = ".$summe."<br>";
echo "Subtraktion: ".$d." - ".$c." = ".$differenz."<br>";
echo "Multiplikation: ".$d." * ".$c." = ".$produkt."<br>";
echo "Division: ".$d." / ".$c." = ".$quotient;
?>