Operator is a symbol or can be a series of symbols, which when used
with some values performs some action and produce a new value.
Assignment Operator
Assignment operator "=" is most widely used operator in PHP. This operator is used to initialize
the variable.This operator is used in between two operands. It evaluates right-hand
operand and assigs its value to the left-hand operand. Most operators are used to produce
some result without changing the value of their operands. But assignment operator breaks
this rule.
print ($name = “John”); //assigns “John” to “$name”, then
outputs “$name”
At the same time you can perform multiple things. So you can assign not only
the word “John” to the variable “$name”, but can also output the variable at (almost)
the same time..
Dot Operator
Using the concatenation operator we can append additional characters to a string.
This is a single dot “.”. Treating both operands as the string types, it appends
the right-hand operand to the left-hand operand, the result is ofcourse, a string.
Arithmetic operators are also used in many programming languages. You know for sure
what each of them do, so we’ll just stick to point them out: addition “+”,
subtraction “-”, division “/”, multiplication “*”, and modulus “%”.
You've already seen some of the arithmetic and string operators in PHP's. However, the language
also comes with operators that are designed specifically to compare two values: These operators
are called "comparison operators". Here's an example to demonstrates Comparison
Operators in action:
// less-than operator
// returns true if left side is less than right
// returns true here
$result = ($mean < $median);
print "result is $result<br /> ";
// greater-than operator
// returns true if left side is greater than right
// returns false here
$result = ($mean > $median);
print "result is $result<br /> ";
// less-than-or-equal-to operator
// returns true if left side is less than or equal to right
// returns false here
$result = ($median <= $mode);
print "result is $result<br /> ";
// greater-than-or-equal-to operator
// returns true if left side is greater than or equal to right
// returns true here
$result = ($median > = $mode);
print "result is $result<br /> ";
// equality operator
// returns true if left side is equal to right
// returns true here
$result = ($mean == $mode);
print "result is $result<br /> ";
// not-equal-to operator
// returns true if left side is not equal to right
// returns false here
$result = ($mean != $mode);
print "result is $result<br /> ";
// inequality operator
// returns true if left side is not equal to right
// returns false here
$result = ($mean <> $mode);
print "result is $result";
php?>
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.