PHP: Introduction Operator

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”;
The result:

Know the assigment operator

The following table of symbols and Functions of the assignment operator used

Example Scripts assignment.php


print “Nilai \$data1 adalah $data1 <br><br>”;

print “Nilai \$data2 adalah $data2 <br><br>”;

print “Nilai \$data3 adalah $data3 <br><br>”;

print “Nilai \$data4 adalah $data4 <br><br>”;

print “Nilai \$data5 adalah $data5”;

The result:

Know Comparison Operators

Table of comparison operators such as below

Example Scripts perbandingan.php

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 “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, 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

$a=”Selamat “;
print “$b <br>”;
$a=”Selamat”; $b.=””;print “$b<br>”;
?>The result:

If you have any questions please comment.

See also  How Writing: PHP Language

Fajar (Ucup)

The owner and author of and also someone who likes to share interesting information with others.

Leave a Reply

Your email address will not be published. Required fields are marked *