Saturday, July 11, 2009

php5-operator

arithmetic operator
+ Addition 2 + 4=6
- Subtraction 6 - 2=4
* Multiplication 5 * 3=15
/ Division 15 / 3 =5
% Modulus 43 % 10 =3(show the remainder)

1.Assignment Operators
operators:-
+=, -=, *=, /=, %=, ^=, .=, &=, |=, <<=, >>=
For example:
$counter += 2; // This is identical to $counter = $counter + 2;
$offset *= $counter;// This is identical to $offset = $offset * $counter;


2.Comparison Operators
Comparison operators enable you to determine the relationship between two operands
== Equal to
Checks for equality between two arguments performing type conversion when necessary:
1 == "1" results in true
1 == 1 results in true

!= Not equal to
Inverse of ==.
> Greater than
Checks if first operand is greater than second
< Smaller than
Checks if first operand is smaller than second
>= Greater than or equal to
Checks if first operand is greater or equal to second
<= Smaller than or equal to
Checks if first operand is smaller or equal to second

3.Logical Operators
Logical operators first convert their operands to boolean values and then perform the respective comparison.
Operator
&&, and
The result of the logical AND operation between the two operands

||, or
if the condition with of any operand is true than result is true
ex-$a=45;
if(a>30||a<50)
echo "arunrawat-web.blogspot.com";
//this print the arunrawat-web.blogspot.com
?>
Xor, Logical XOR
The result of the logical XOR operation between the two operands

increment/decrement operator
$var++, Post-increment
$var is incremented by 1.
The previous value of $var.

++$var, Pre-increment
$var is incremented by 1.
The new value of $var (incremented by 1).

$var--
Post-decrement
$var is decremented by 1.
The previous value of $var.

--$var, Pre-decrement
$var is decremented by 1.
The new value of $var (decremented by 1).

No comments:

Post a Comment