[go: up one dir, main page]

0% found this document useful (0 votes)
11 views9 pages

PHP Operator Examples Tutorial

Uploaded by

Nazelda Rani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views9 pages

PHP Operator Examples Tutorial

Uploaded by

Nazelda Rani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

<html>

<head>

<title>Tugas_3_Pemograman_Web</title>

</head>

<body>

<?php

$nama="Nazelda Rani";

$matakuliah="Pemograman Web";

$semester="IV";

$c=2;

$d=7;

$e=4;

$f=5;

$g=1;

$a=4;

$b=$a;

$nilaia=$a=$a + $e;

$nilaib=$a=$a - $g;

$nilaic=$a=$a * $f;

$nilaid=$a=$a / $d;

$nilaie=$a=$a / 100 * $c;

echo "<h2><center><u>OPERATOR PENUGASAN</u></center></h2><hr>";

echo"<br>A = $b</br>";

echo"<h2><center><u>Contoh Soal</u></center></h2><hr>";

echo"<br>A = A + $e</br>";
echo"<br>A=<u>$nilaia</u></br>";

echo"<br>A = A - $g</br>";

echo"<br>A=<u>$nilaib</u></br>";

echo"<br>A = A * $f</br>";

echo"<br>A=<u>$nilaic</u></br>";

echo"<br>A = A / $d</br>";

echo"<br>A=<u>$nilaid</u></br>";

echo"<br>A = A % $c</br>";

echo"<br>A=<u>$nilaie</u></br>";

echo"<br><b><u><center>$nama</br>";

echo"<br>$matakuliah</br>";

echo"<br>$semester</br></b></u></center>";

?>

</body>

</html>
<html>

<head>

<title>Tugas_3_Pemograman_Web</title>

</head>

<body>

<?php

$nama="Nazelda Rani";

$matakuliah="Pemograman Web";

$semester="IV";

$x=10;

$y=8;

echo "<h2><center><u>OPERATOR PEMBANDING</u></center></h2><hr>";

echo"<br>X : 10</br>";

echo"<br>Y : 8</br>";

echo"<h2><center><u>Contoh Soal</u></center></h2><hr>";

if($x==$y){

echo "<br>X == Y : Benar</br>";

}else{

echo "<br>X == Y : Salah</br>";

if($x!=$y){

echo "<br>X != Y : Benar</br>";

}else{

echo "<br>X != Y : Salah</br>";

}
if($x<$y){

echo "<br>X < Y : Benar</br>";

}else{

echo "<br>X < Y : Salah</br>";

if($x>$y){

echo "<br>X > Y : Benar</br>";

}else{

echo "<br>X > Y : Salah</br>";

if($x<=$y){

echo "<br>X <= Y : Benar</br>";

}else{

echo "<br>X <= Y : Salah</br>";

if($x>=$y){

echo "<br>X >= Y : Benar</br>";

}else{

echo "<br>X >= Y : Salah</br>";

echo"<br><b><u><center>$nama</br>";

echo"<br>$matakuliah</br>";

echo"<br>$semester</br></b></u></center>";

?>

</body>
</html>
<html>

<head>

<title>Tugas_3_Pemograman_Web</title>

</head>

<body>

<?php

$nama="Nazelda Rani";

$matakuliah="Pemograman Web";

$semester="IV";

$nilai1=8;

$nilai2=10;

$nilaia=$nilai1+$nilai2;

$nilaib=$nilai1-$nilai2;

$nilaic=$nilai1*$nilai2;

$nilaid=$nilai1/$nilai2;

$nilaie=$nilai1%$nilai2;

echo"<h2><center><u>Operator Matematika</u></h2><br>";

echo"<br>Nilai1 =$nilai1</br>";

echo"<br>Nilai2 =$nilai2</br>";

echo"<h2><center><u>Contoh Soal</u></h2><hr>";

echo"<br>$nilai1+$nilai2=$nilaia</br>";

echo"<br>$nilai1-$nilai2=$nilaib</br>";

echo"<br>$nilai1*$nilai2=$nilaic</br>";

echo"<br>$nilai1/$nilai2=$nilaid</br>";

echo"<br>$nilai1%$nilai2=$nilaie</br>";
echo"<br>";

echo"<br>";

echo"<br>";

echo"<br><b><u><center>$nama</br>";

echo"<br>$matakuliah</br>";

echo"<br>$semester</br></b></u></center>";

?>

</body>

</html>
<html>

<head>

<title>Tugas_3_Pemograman_Web</title>

</head>

<body>

<?php

$nama="Nazelda Rani";

$matakuliah="Pemograman Web";

$semester="IV";

$a=8;

$b=10;

echo "<h2><center><u>OPERATOR LOGIKA</u></center></h2><hr>";

echo"<br>A : 8</br>";

echo"<br>B : 10</br>";

echo"<h2><center><u>Contoh Soal</u></center></h2><hr>";

if($a==8 and $b==10){

echo"Logika AND<br>(A == 8 and B == 10)</br><b>Benar</b>";}

else

{echo"Logika AND<br>(A == 8 and B == 10)</br><b>Salah</b></br>";}

if($a==8 || $b==9){

echo"<br><br>Logika OR<br>(A == 8 or B == 9)</br><b>Benar</b>";}

else

{echo"<br><br>Logika OR<br>(A == 8 or B == 9)</br><b>Salah</b></br>";}

if($a==9 xor $b==9){

echo"<br><br>Logika XOR<br>(A == 9 xor B == 9)</br><b>Benar</b>";}


else

{echo"<br><br>Logika XOR<br>(A == 9 xor B == 9)</br><b>Salah</b></br>";}

if($a !== 8){

echo"<br><br>Logika NOT<br>(A !== 8)</br><b>Benar</b>";}

else

{echo"<br><br>Logika NOT<br>(A !== 8)</br><b>Salah</b></br>";}

echo"<br><b><u><center>$nama</br>";

echo"<br>$matakuliah</br>";

echo"<br>$semester</br></b></u></center>";

?>

</body>

</html>

You might also like