Professional Documents
Culture Documents
NPM: 21100067
Sesi: 21/B
Tugas: PBW
Hasil run
2. Contoh 2
Code
<html>
<head>
<title> Contoh Skrip PHP </title>
<body>
<?php
$a=3;
$b=7;
$a +=5;
$b = ($c = 11) + 3;
echo "Nilai Variabel a adalah = $a";
echo "<br>";
echo "Nilai Variabel b adalah = $b";
echo "<br>";
echo "Nilai Variabel c adalah = $c";
?>
</body>
</html>
Hasil run
3. Contoh 3
Code
<html>
<head>
<title> Contoh Skrip PHP </title>
<body>
<?php
$a=3;
$b=7;
$a +=5;
$b = ($c = 11) + 3;
echo "Nilai Variabel a adalah = $a";
echo "<br>";
echo "Nilai Variabel b adalah = $b";
echo "<br>";
echo "Nilai Variabel c adalah = $c";
?>
</body>
</html>
Hasil run
4. Contoh 4
Code
<html>
<head>
<title> Contoh Skrip PHP </title>
<body>
<?php
$nilai = 85;
$nama = "Amir" ;
if ($nilai >= 80)
{
echo $nama. "Mendapat nilai A";
}
elseif ($nilai >= 70)
{
echo $nama. "Mendapat nilai B";
}
elseif ($nilai >= 60)
{
echo $nama. 'Mendapat nilai C';
}
else
{
echo $nama. "Mendapat nilai D";
}
?>
</body>
</html>
Hasil run
5. Contoh 5
Code
<html>
<head>
<title>Contoh skrip PHP</title>
</head>
<body>
<form method="post" action="">
Tanggal Lahir:
<select name="tanggal">
<option value="0" selected>Tanggal</option>
<?php
for ($i = 1; $i < 32; $i++) {
echo "<option value='$i'>$i</option>";
}
?>
</select>
</form>
</body>
</html>
Hasil run
6. Contoh 6
Code
<html>
<head>
<title> Contoh Skrip PHP </title>
</head>
<body>
<?php
$i = 1;
do
{
echo "$i <br>";
$i++;
} while($i <= 5);
?>
</body>
</html>
Hasil run