Table of arithmetic operators
Sample Script aritmatika.php
<? php
$ value1 = 32;
$ value2 = 8;
$ number = $ value1 + $ value2;
$ less = $ nilai1- $ value2;
$ time = $ value1 * $ value2;
$ to = $ value1 / $ value2;
$ remainder = $ value1% $ value2;
print "Reviews Arithmetic operation Example";
print "The value \ $ value1 = $ value1 and \ $ value2 = $ nilai2 <br>";
print "\ $ value1 + \ $ value2 = $ amount most";
print "\ $ value1 - \ $ value2 = $ less than most";
print "\ $ value1 * \ $ value2 = $ times the most";
print "\ $ value1 / \ $ value2 = $ for most";
print "\ $ value1% \ $ value2 = $ leftovers most";
?>
$ value1 = 32;
$ value2 = 8;
$ number = $ value1 + $ value2;
$ less = $ nilai1- $ value2;
$ time = $ value1 * $ value2;
$ to = $ value1 / $ value2;
$ remainder = $ value1% $ value2;
print "Reviews Arithmetic operation Example";
print "The value \ $ value1 = $ value1 and \ $ value2 = $ nilai2 <br>";
print "\ $ value1 + \ $ value2 = $ amount most";
print "\ $ value1 - \ $ value2 = $ less than most";
print "\ $ value1 * \ $ value2 = $ times the most";
print "\ $ value1 / \ $ value2 = $ for most";
print "\ $ value1% \ $ value2 = $ leftovers most";
?>
Know the assigment operator
The following table of symbols and Functions of the assignment operator used
Example Scripts assignment.php
<?php
$data1=10;
$data1+=2;
print "Nilai \$data1 adalah $data1 <br><br>";
$data2=10;
$data2-=5;
print "Nilai \$data2 adalah $data2 <br><br>";
$data3=10;
$data3*=4;
print "Nilai \$data3 adalah $data3 <br><br>";
$data4=20;
$data4/=5;
print "Nilai \$data4 adalah $data4 <br><br>";
$data5=12;
$data5%=7;
print "Nilai \$data5 adalah $data5";
?>
$data1=10;
$data1+=2;
print "Nilai \$data1 adalah $data1 <br><br>";
$data2=10;
$data2-=5;
print "Nilai \$data2 adalah $data2 <br><br>";
$data3=10;
$data3*=4;
print "Nilai \$data3 adalah $data3 <br><br>";
$data4=20;
$data4/=5;
print "Nilai \$data4 adalah $data4 <br><br>";
$data5=12;
$data5%=7;
print "Nilai \$data5 adalah $data5";
?>
Example Scripts perbandingan.php
<?php
$a=12;
$b=13;
print "Variabel \$a = $a dan \$b = $b <br><br>";
print("Nilai \$a == \$b adalah %s <br>",$a==$b);
print("Nilai \$a <> \$b adalah %d <br>",$a<>$b);
print("Nilai \$a > \$b adalah %d <br>",$a>$b);
print("Nilai \$a < \$b adalah %d <br>",$a<$b);
print("Nilai \$a <= \$b adalah %d <br>",$a<=$b);
print("Nilai \$a >= \$b adalah %d <br><br>",$a>=$b);
print"Keterangan:<br>";
print "Nilai 1 berarti Benar/True<br>";
print "Nilai 0 berarti Salah/False";
?>
$a=12;
$b=13;
print "Variabel \$a = $a dan \$b = $b <br><br>";
print("Nilai \$a == \$b adalah %s <br>",$a==$b);
print("Nilai \$a <> \$b adalah %d <br>",$a<>$b);
print("Nilai \$a > \$b adalah %d <br>",$a>$b);
print("Nilai \$a < \$b adalah %d <br>",$a<$b);
print("Nilai \$a <= \$b adalah %d <br>",$a<=$b);
print("Nilai \$a >= \$b adalah %d <br><br>",$a>=$b);
print"Keterangan:<br>";
print "Nilai 1 berarti Benar/True<br>";
print "Nilai 0 berarti Salah/False";
?>
There are other operators are included in the category of comparison operators are ternary operator " ?". The use of the ternary operator is identical to the user if .. else . Pnggunaan example of the ternary operator is as follows:
Example Scripts ternary.php
The result:
Know the String Operator
There are two types of operators used string operators . (Dot) operator . = (Colon equals) operator . concatenate the arguments sent word to say that the right in an argument. While the operator . =Concatenate the arguments with a right hand to the left. The second function is similar operator to concatenate the words before and after. But the use of the operator. = More practical and operational results can be saved to the same variable. For more details, you can try the following script program. script String.php
<?php
$a="Selamat ";
$b=$a."Datang";
print "$b <br>";
$a="Selamat"; $b.="";print "$b<br>";
?>
$a="Selamat ";
$b=$a."Datang";
print "$b <br>";
$a="Selamat"; $b.="";print "$b<br>";
?>
The result:
If you have any questions please comment.
Comments