# Php Operators and their Description Php Operators and their Description

# Php Operators to test if two values are identical

Php Operators: A Php Language is a Special operator that is a mathematical operation performed in the Php language. Operator Can be used to solve the mathematical process and Perform logically. Operators have used variables and data calculation.

# 1. Arithmetic Operator2. Relational Operator3. Logical Operator 4. Assignment operator5. Bitwise Operator6. Increment operator7. Decrement Operator8. Conditional Operator

## Php Arithmetic operators

Arithmetic Operator: A arithmetic operation is a used mathematical operation performed.

It is many operations performed like addition, subtraction, multiplication, and division.

Example of Arithmetic operator

Here a is operands value (+) Addition is operator and b is operands. It can be used for additional operations performed.

Subtraction: a-b or 20-10=10

Here a is operands value (-) Subtraction sign is operator and b is operands. It can be used as Subtraction operations performed.

Multiplication: a*b or 10*10=100

Here a is operands value (*) Multiplication sign is operator and b is operands. It can be used for Multiplication operations performed.

Division: a/b or 10/5=2

Here a is operands value (/) Division sign operator and b is operands. It can be used for Division operations performed.

Modules: a%b or 10%3=1

Here a is operands value (%) Modules sign operator and b is operands. It can be used to Modules operations performed.

### Php Arithmetic Operator Table

 Sign Operation Example (+) Addition (x+y) (-) Subtraction (x-y) (/) Multiplication (x*y) (*) Division (x/y) (%) Modules (x%y)

### Arithmetic Operator in Php?

 "; echo "Subtraction:".(\$x-\$y)."
"; echo "Multiplication:".(\$x*\$y)."
"; echo "Division:".(\$x/\$y)."
"; echo "Modules:".(\$x%\$y)."

## Php Comparison Operators

Comparison Operator: Comparison operators are used in the comparison of the two operands. It can be using equal operands and condition checks in this operator. The Comparison operator is very the most useful operator.

Php Comparision Operator Table

 Sign Operation Example (==) Equal (a=b) (!=) Not Equal To (!a=b) (>) Greater Than (a>b) (<) Less Than (a=) Greater Than or Equal (a>=b) (<=) Less Than or Equal (a<=b)

### Php Comparison Operator

 \$b) + "\n";var_dump(\$a === \$c) + "\n";var_dump(\$a !== \$c) + "\n";var_dump(\$a < \$b) + "\n";var_dump(\$a > \$b) + "\n";var_dump(\$a <= \$b) + "\n";var_dump(\$a >= \$b);?>*****OUTPUT*****bool(true)bool(true)bool(true)bool(false)bool(true)bool(false)bool(true)bool(false)bool(true)

## Php Logical Operators

Logical Operators: PHP Language provides three logical operators. logical Operator tests more than one condition to make decisions.

Types of Logical Operator

1.&& AND Operator

2.|| OR Operator

3.!  NOT Operator

1. AND Operator can be used decisions are two values.AND Operator two values are True AND Operator return True. But two values are anyone False AND Operator return False.

2. OR operator performs a logical condition on two expressions. if or Operator can be two expressions are True OR Operator return true. But any of the expressions are False OR Operator return True.

3. NOT operator is elementary Operator. it can be used condition are True NOT Operator returns False and condition are False NOT Operator returns True.

Logical Operator in php?

 =60) {  echo "First division
"; } if(\$marks<60 && \$marks>=45) { echo "Second division
"; } if(\$marks<45 && \$marks>=33) { echo "Third division
"; } if(\$marks<33) { echo "Sorry!! You are Fail!!
"; } ?>*****OUTPUT*****Second division

## Php Assignment Operator Table

 Sign Operation Example (=) a=b (a=b) (+=) a+=b (a=a+b) (-=) a-=b (a=a-b) (*=) a*=b (a=a*b) (/=) a/=b (a=a/b) (%=) a%=b (a=a%b)

## Php Bitwise Operators

Bitwise Operator: A Bitwise operator is an operation performed on the data bit level. the bitwise operator also shifts bit right to left.

Note: Bitwise operators are not allowed to float and double.

### Bitwise Operator Table

 Sign Operation Example (&) Bitwise AND (a&b) (|) Bitwise OR (a|b) (<<) Bitwise LEFT (a<>) Bitwise RIGHT (a>>b)

Bitwise Operator in php?

 "; echo "x|y:".(\$x|\$y)."
"; echo "x>>1:".(\$x>>1)."
"; echo "x<<2:".(\$x<<2)."
"; echo "x^y:".(\$x^\$y)."
"; ?> *****OUTPUT*****x&y=1 x|y=7 x>>1=1 x<<2=12 x^y=6

## Php Increment/Decrement Operator

Increment Operator: Increment Operators are useful operators generally used.like++x and x++ means x=x+1.

pre-increment first adds one to the operand and then the result is assigned to the variable on the left.

post-increment first assigns the value to the variable on the left and then increments the operand.

Decrement Operator: A Decrement Operator has used the decrease the value. like --x and x--.

Pre-decrement first less one to the operands and then the result is assigned to the variable on the left.

Post-decrement first assigns the value to the variables on the left and then decrements the operands.

### increment/decrement operator

 "; echo "Decrement --y:".--\$y."
"; ?>*****OUTPUT*****Increment ++x:4 Decrement --y:4

## Php Conditional  Operator

Conditional Operators: If the condition is true second part will execute otherwise third part will execute.

### Conditional Operator in Php

 \$y?"x is greater":"y is greater"; echo \$str; ?*****OUTPUT*****y is greater