PHP: Introduction Operator
$ 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
";
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
$data1+=2;
print "Nilai $data1 adalah $data1
";
$data2=10;
$data2-=5;
print "Nilai $data2 adalah $data2
";
$data3=10;
$data3*=4;
print "Nilai $data3 adalah $data3
";
$data4=20;
$data4/=5;
print "Nilai $data4 adalah $data4
";
$data5=12;
$data5%=7;
print "Nilai $data5 adalah $data5";
?>
$b=13;
print "Variabel $a = $a dan $b = $b
";
print("Nilai $a == $b adalah %s
",$a==$b);
print("Nilai $a <> $b adalah %d
",$a<>$b);
print("Nilai $a > $b adalah %d
",$a>$b);
print("Nilai $a < $b adalah %d
",$a<$b);
print("Nilai $a <= $b adalah %d
",$a<=$b);
print("Nilai $a >= $b adalah %d
",$a>=$b);
print"Keterangan:
";
print "Nilai 1 berarti Benar/True
";
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:
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
$b=$a."Datang";
print "$b
";
$a="Selamat"; $b.="";print "$b
";
?>
The result:
If you have any questions please comment.