Friday, October 1, 2010

The Concatenation Operator in Php

The concatenation operator is a single dot. Treating both operands as strings, it
appends the right-hand operand to the left. So
"hello"." world"
returns
"hello world"
Regardless of the data types of the operands, they are treated as strings, and the
result always is a string.

Arithmetic Operators in Php

The arithmetic operators do exactly what you would expect. Table 4.2 lists these
operators. The addition operator adds the right operand to the left operand. The
subtraction operator subtracts the right-hand operand from the left. The division
operator divides the left-hand operand by the right. The multiplication operator
multiplies the left-hand operand by the right. The modulus operator returns the
remainder of the left operand divided by the right.


Operator Name    Example      Example Result
+       Addition          10+3                   13
−       Subtraction    10− 3                    7
/        Division           10/3         3.3333333333333
*      Multiplication    10*3                  30
%       Modulus        10%3                 1

The Assignment Operator in Php

You have met the assignment operator each time we have initialized a variable. It
consists of the single character =. The assignment operator takes the value of its
right-hand operand and assigns it to its left-hand operand:
$name ="matt";
The variable $name now contains the string "matt". Interestingly, this construct is
an expression. It might look at first glance that the assignment operator simply
changes the variable $name without producing a value, but in fact, a statement that
uses the assignment operator always resolves to a copy of the value of the right
operand. Thus
print ( $name = "matt" );
prints the string "matt" to the browser in addition to assigning "matt" to $name.
Arithmetic Operators