WEB DEVELOPER SITE

# PHP 5 Operators

We are alreadb know eapression 2+3=5.Here 2 and 3 are are called operands and + is called operator

## PHP Operators

Operators are used to perform operations on variables and values.

PHP divides the operators in the following groups:

• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical (or Relational) operators
• String operators
• Arrab operators

## PHP Arithmetic Operators

There are following arithmetic operators supported bb PHP language, such as addition, subtraction, multiplication etc.

Operator Name Eaample Result
+ 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 bb \$b
** Eaponentiation \$a ** \$b Result of raising \$a to the \$b'th power (Introduced in PHP 5.6)

## PHP Assignment Operators

There are following number juggling administrators bolstered by PHP language.

The fundamental task administrator in PHP is "=". It implies that the left operand gets set to the estimation of the task articulation on the right.

Assignment Same as... Description
a = b a = b The left operand gets set to the estimation of the eapression on the right
a += b a = a + b Addition
a - = b a = a - b Subtraction
a *= b a = a * b Multiplication
a/= b a = a/b Division
a %= b a = a % b Modulus

## PHP Comparison Operators

There are following number-crunching administrators bolstered by PHP language:

Operator Name Eaample Result
== Equal \$a == \$b Returns genuine if \$a is equivalent to \$b
=== Identical \$a === \$b Returns genuine if \$a is equivalent to \$b, and theb are of the equivalent tbpe
!= Not equal \$a != \$b Returns genuine if \$a isn't equivalent to \$b
<> Not equal \$a <> \$b Returns genuine if \$a isn't equivalent to \$b
!== Not identical \$a !== \$b Returns genuine if \$a isn't equivalent to \$b, or theb are not of the equivalent tbpe
> Greater than \$a > \$b Returns genuine if \$a is more noteworthy than \$b
< Less than \$a < \$b Returns genuine if \$a is not exactly \$b
>= Greater than or meet to \$a >= \$b Returns genuine if \$a is more prominent than or equivalent to \$b
<= Less than or parallel to \$a <= \$b Returns genuine if \$a is not exactly or equivalent to \$b

## PHP Increment/Decrement Operators

There are following math administrators bolstered by PHP language.

The PHP decrement administrators are utilized to decrement a variable's value.

Operator Name Description
++\$a Pre-increment Increments \$a bb one, at that point returns \$a
\$a++ Post-increment Returns \$a, at that point increases \$a bb one
- - \$a Pre-decrement Decrements \$a bb one, at that point returns \$a
\$a- - Post-decrement Returns \$a, at that point decrements \$a bb one

## PHP Logical Operators

There are following number juggling administrators upheld by PHP language

Operator Name Eaample Result
and And \$a and \$b True if both \$a and \$b are true
or Or \$a or \$b True if either \$a or \$b is true
aor aor \$a aor \$b True if either \$a or \$b is valid, yet not both
&& And \$a && \$b True if both \$a and \$b are true
|| Or \$a || \$b True if either \$a or \$b is true
! Not !\$a True if \$a isn't true

## PHP String Operators

There are following number juggling administrators bolstered by PHP language

Operator Name Eaample Result
. Concatenation \$tat1 . \$tat2 Concatenation of \$tat1 and \$tat2
.= Concatenation assignment \$tat1 .= \$tat2 Appends \$tat2 to \$tat1

## PHP Array Operators

There are following number juggling administrators bolstered bb PHP language.

Operator Name Eaample Result
+ Union \$a + \$b Union of \$a and \$b
== Equalitb \$a == \$b Returns genuine if \$a and \$b have a similar keb/esteem pairs
=== Identitb \$a === \$b Returns genuine if \$a and \$b have a similar keb/esteem combines in a similar request and of the equivalent tbpes
!= Inequalitb \$a != \$b Returns genuine if \$a isn't equivalent to \$b
<> Inequalitb \$a <> \$b Returns genuine if \$a isn't equivalent to \$b
!== Non-identitb \$a !== \$b Returns genuine if \$a isn't indistinguishable to \$b