29 Jan 2014

OPERATORS IN PHP :- Arithmetic Operator

PHP can perform simple Mathematical operations all the way to complex trigonometric equations.


















OPERATORS IN PHP :- Logical Operators

Logical operators are used when we want to combine operations and expressions into a set of logical comparisons. They are usually used in conjuction with "if and "else" statements to lay out the dynamic logic we need in many situations as we advance in our PHP development.

Name Usage Result
And $var1 && $var2 TRUE if both $var1 and $var2 are TRUE
And $var1 and $var2 TRUE if both $var1 and $var2 are TRUE
Or $var1 or $var2 TRUE if either $var1 or $var2 is TRUE
Or $var1 || $var2 TRUE if either $var1 or $var2 is TRUE
Xor $var1 xor $var2 TRUE if either $var1 or $var2 is TRUE, but not both
Is Not !$var1 TRUE if $var1 is not TRUE



example:-


28 Jan 2014

OPERATORS IN PHP :- Comparison Operators

PHP comparison operators allow you to compare two values against each other.The comparison is read from left to right by the PHP engine. Widely use in Conditional Logic and Control Structures.

  1. Equal    :- $var1 == $var2  Result :- TRUE if $var1 is equal to $var2.
  2. Identical    :- $var1 === $var2  Result :- TRUE if $var1 is equal to $var2, and they are of the same type
  3. Not Equal    :- $var1 != $var2 Result :- TRUE if $var1 is not equal to $var2
  4. Not Equal    :- $var1 < > $var2  Result :- TRUE if $var1 is not equal to $var2.
  5. Not Identical    :- $var1 !== $var2  Result :- TRUE if $var1 is not equal to $var2, or they are not the same type.
  6. Less Than    :- $var1 < $var2   Result :- TRUE if $var1 is strictly less than $var2.
  7. Greater Than    :- $var1 > $var2   Result :- TRUE if $var1 is strictly greater than $var2.
  8. Less Than or Equal to    :- $var1 <= $var2   Result :- TRUE if $var1 is less than or equal to $var2.
  9. Greater Than or Equal to    :- $var1 >= $var2   Result :- TRUE if $var1 is greater than or equal to $var2.
 example
 

OPERATORS IN PHP :- Concatenation

The concatenation operator ( . ) returns the combined value of its right and left values.
The variable's data type has an affect on the output.

example :-

















The concatenating assignment operator ( .= ), which appends the variable value on the right side to the variable on the left side. We use this method many times to compound and keep adding to one variable so it will retain its current value, and just append the new values onto the current value's tail end.

example :-

OPERATORS IN PHP :- Increment and Decrement operator

Incrementing and Decrementing operators are very widely used in most programming languages. They allow a PHP programmer to increment and decrement values as needed.
  1. Pre-Increment     ++$MyVariable  Result Increments $MyVariable by one.
  2. Post-Increment    $MyVariable++ Result Returns $MyVariable, then increments $myVar by one.
  3. Pre-Decrement    --$MyVariable  Result Decrements $MyVariable by one.
  4. Post-Decrement   $MyVariable-- Result Returns $MyVariable, then decrements $myVar by one.
example:-
 

OPERATORS IN PHP :- The Assignment operator


The Assignment operator is the most widely used in PHP.
We use it every time you create a variable.
The "="(equal to) sign is used, and what it does is it takes the expression from the right and places it into the operand on the left. It is simple.

example:-