<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
// Operator assignment
echo "============================================Operator Assignment=============================================";
echo "<br/><br/>";
echo '$var1 = 2;' . "<br/>";
echo '$var2 = 3;' . "<br/>";
echo '$var3 = 4;' . "<br/><br/>";
echo '$var3 += $var2;' . "<br/>";
$var1 = 2;
$var2 = 3;
$var3 = 4;
echo "$var3" . " += " . " $var2 " . " = " . $var3 += $var2;
$var3 += $var2;
echo "<br/>";
// Operator aritmatika
echo "============================================Operator Artimatika=============================================";
echo "<br/><br/>";
echo '$var_tambah = $var1 + $var2;' . "<br/>";
echo "$var1 " . " + " . " $var2 " . " = " . $var_tambah = $var1 + $var2 . "<br/><br/>";
echo '$var_kurang = $var1 - $var2;' . "<br/>";
echo "$var1 " . " - " . " $var2 " . " = " . $var_tambah = $var1 - $var2 . "<br/><br/>";
echo '$var_kali = $var1 * $var2;' . "<br/>";
echo "$var1 " . " * " . " $var2 " . " = " . $var_tambah = $var1 * $var2 . "<br/><br/>";
echo '$var1 / $var2;' . "<br/>";
echo "$var1 " . " / " . " $var2 " . " = " . $var_tambah = $var1 / $var2 . "<br/><br/>";
echo '$var1 % $var2;' . "<br/>";
echo "$var1 " . " % " . " $var2 " . " = " . $var_tambah = $var1 % $var2 . "<br/><br/>";
$var_tambah = $var1 + $var2;
$var_kurang = $var1 - $var2;
$var_kali = $var1 * $var2;
$var_bagi = $var1 / $var2;
$var_sisa_bagi = $var1 % $var2;
/* echo $var_tambah . "<br/>";
echo $var_kurang . "<br/>";
echo $var_kali . "<br/>";
echo $var_bagi . "<br/>";
echo $var_sisa_bagi . "<br/>";
*/
echo "==========================================Operator Relational / Comparation====================================";
echo "<br/><br/>";
// Operator relational / comparation
if ($var1 == $var2){
echo $var1 . " == " . $var2 . " = TRUE <br/> ";
}else{
echo $var1 . " == " . $var2 . " = FALSE <br/> ";
}
echo "$var1 != $var2 = "; var_dump($var1 != $var2); echo "<br/>";
echo "$var1 < $var2 = "; var_dump($var1 < $var2); echo "<br/>";
echo "$var1 > $var2 = "; var_dump($var1 > $var2); echo "<br/>";
echo "$var1 <= $var2 = "; var_dump($var1 <= $var2); echo "<br/>";
echo "$var1 >= $var2 = "; var_dump($var1 >= $var2); echo "<br/><br/>";
echo "==========================================Operator Logical ================================================";
echo "<br/><br/>";
// logical operator
echo '($var1 == 2 AND $var2 == 3) '; echo var_dump($var1 == 2 AND $var2 == 3) . "<br/>";
echo '($var1 == 2 AND $var2 == 4) '; echo var_dump($var1 == 2 AND $var2 == 4) . "<br/>";
echo "<br/>";
echo '($var1 == 2 && $var2 == 3) '; echo var_dump($var1 == 2 && $var2 == 3) . "<br/>";
echo '($var1 == 2 && $var2 == 4) '; echo var_dump($var1 == 2 && $var2 == 4) . "<br/>";
echo "<br/>";
echo '($var1 == 2 OR $var2 == 3) '; echo var_dump($var1 == 2 Or $var2 == 3) . "<br/>";
echo '($var1 == 2 OR $var2 == 4) '; echo var_dump($var1 == 2 Or $var2 == 4) . "<br/>";
echo "<br/>";
echo '($var1 == 2 || $var2 == 3) '; echo var_dump($var1 == 2 || $var2 == 3) . "<br/>";
echo '($var1 == 2 || $var2 == 4) '; echo var_dump($var1 == 2 || $var2 == 4) . "<br/>";
echo "<br/>";
echo '($var1 == 2 XOR $var2 == 3) '; echo var_dump($var1 == 2 XOR $var2 == 3) . "<br/>";
echo '($var1 == 2 XOR $var2 == 4) '; echo var_dump($var1 == 2 XOR $var2 == 4) . "<br/>";
echo "<br/>";
echo '(!$var1 == 2 XOR $var2 == 3) '; echo var_dump(!$var1 == 2 XOR $var2 == 3) . "<br/>";
echo '($var1 == 2 XOR $var2 == 4) '; echo var_dump($var1 == 2 XOR $var2 == 4) . "<br/>";
?>
</body>
</html>
Tidak ada komentar