With what you have learned so far, you can assign data to variables. You can even investigate and change the data type of a variable. A programming language isn't very useful, though, unless you can manipulate the data you can store. Operators are symbols that make it possible to use one or more values to produce a new value. A value that is operated on by an operator is referred to as an operand.Tips:-
The basic assignment operator is "=". Your first inclination might be to think of this as "equal to". Don't. It really means that the the left operand gets set to the value of the expression on the rights (that is, "gets set to").
|Operator||Example||Is The Same As|
The value of an assignment expression is the value assigned. That is, the value of "$a = 3" is 3. This allows you to do some tricky things:
The arithmetic operators do exactly what you would expect—they perform arithmetic operations.
Remember basic arithmetic from school ? These work just like those.
|Addition (+)||$a + $b||Sum of $a and $b.|
|Subtraction (-)||$a - $b||Difference of $a and $b.|
|Multiplication (*)||$a * $b||Product of $a and $b.|
|Division (/)||$a / $b||Quotient of $a and $b.|
|Modulus (%)||$a % $b||Remainder of $a divided by $b.|
The comparison operators perform tests on their operands. They return the Boolean value true if the test is successful, or false otherwise. This type of expression is useful in control structures, such as if and while statements.
|Equal (==)||$a == $b||TRUE if $a is equal to $b.|
|Identical (===)||$a === $b||TRUE if $a is equal to $b, and they are of the same type. (PHP 4 only)|
|Not equal (!=)||$a != $b||TRUE if $a is not equal to $b.|
|Not equal (<>)||$a <> $b||TRUE if $a is not equal to $b.|
|Not identical (!==)||$a !== $b||TRUE if $a is not equal to $b, or they are not of the same type. (PHP 4 only)|
|Less than (<)||$a < $b||TRUE if $a is strictly less than $b.|
|Greater than (>)||$a > $b||TRUE if $a is strictly greater than $b.|
|Less than or equal to (<=)||$a <= $b||TRUE if $a is less than or equal to $b.|
|Greater than or equal to (>=)||$a >= $b||TRUE if $a is greater than or equal to $b.|
The logical operators test combinations of Booleans. For example, the or operator, which is indicated by two pipe characters (||) or simply the word or, returns true if either the left or the right operand is true:
true || false
This expression returns true.
|And (&&)||$a and $b||TRUE if both $a and $b are TRUE.|
|Or (||)||$a or $b||TRUE if either $a or $b is TRUE.|
|Xor||$a xor $b||TRUE if either $a or $b is TRUE, but not both.|
|Not (!)||! $a||TRUE if $a is not TRUE.|
?To err is human, but to really foul things up requires a computer.
?Treat your password like your toothbrush. Don't let anybody else use it, and get a new one every six months.