INI Scriptnya :
$nilai1=32;
$nilai2=8;
$jumlah=$nilai1+$nilai2;
$kurang=$nilai1-$nilai2;
$kali=$nilai1*$nilai2;
$bagi=$nilai1/$nilai2;
$sisa=$nilai1%$nilai2;
print "Contoh operasi Aritmatika
";
print "Nilai \$nilai1=$nilai1 dan \$nilai2=$nilai2
";
print "\$nilai1 + \$nilai2 = $jumlah
";
print "\$nilai1 - \$nilai2 = $kurang
";
print "\$nilai1 * \$nilai2 = $kali <:br>"; print "\$nilai1 / \$nilai2 = $bagi
"; print "\$nilai1 % \$nilai2 = $sisa
"; ?>
INI Scriptnya :
for ($i = 1; $i <= 5; $i++) { print $i ."
"; } $bila = 5; $pola = 1; print "
Bilangan ganjil antara 5 sampai 25
";
for ($pola=1; $pola<10; style="font-weight: bold;">Foreach
INI Scriptnya :
$klub = array ("Persik Kediri", "Persebaya Surabaya", "PSIS Semarang", "Persipura Jayapura");
print "Klub-klub yang pernah juara Liga Indonesia :
";
foreach ($klub as $nilai)
{
print "$nilai
";
}
?>
Jumat, 30 Oktober 2009
SCRIPT PHP
Diposting oleh FiRLiA di 19.38 0 komentar
CONTOH TAMPILAN SCRIPT
ini scriptnya :
< ?php
header(" Content-Type:image/jpeg" );
$background=@imagecreate(100,100);
$kuning=imagecolorallocate($background,250,250,300);
$hitam=imagecolorallocate($background,0,0,0);
imagearc($background,50,50,50,50,0,360,$hitam);
imageJPEG($background);
imagedestroy($background);
? >
< ?php header(" Content-Type:image/jpeg" ); $background=@imagecreate(100,100); $kuning=imagecolorallocate($background,250,250,300); $hitam=imagecolorallocate($background,0,0,0); imagearc($background,50,50,50,50,0,360,$hitam); imageJPEG($background); imagedestroy($background); ? >
< ?php $a = 2; $b = 15; print " \$a = $a dan \$b = $b
" ; if ($a > $b) { print ;" Nilai a lebih besar dari nilai b;" ; } else { print ;" Nilai a lebih kecil dari nilai b;" ; } ?>
< ?php $cfile = " datapengunjung.dat" ; $fh = fopen($cfile, " r+" ); if (!$fh){ die(" Gagal membuka file <> $cfile< /I> . " );
}
$s = fgets($fh, 6);
$hitung = (int) $s;
$hitung = $hitung + 1;
$hitung = str_pad($hitung, 6);
rewind($fh);
fwrite($fh, $hitung);
echo " Anda pengunjung ke $hitung" ;
fclose($fh);
? >
< ?php $cfile = " datapengunjung.dat" ; $fh = fopen($cfile, " r+" ); if (!$fh){ die(" Gagal membuka file <> $cfile< /I> . " );
}
$s = fgets($fh, 6);
$hitung = (int) $s;
$hitung = $hitung + 1;
$hitung = str_pad($hitung, 6);
rewind($fh);
fwrite($fh, $hitung);
echo " Anda pengunjung ke $hitung" ;
fclose($fh);
? >
< ?php $dir = opendir(" ./ " ); while ($baca_file = readdir($dir)) { echo " $baca_file" , " \n" ; } closedir($dir); ? >
Diposting oleh FiRLiA di 19.24 0 komentar