Loading...

PHP Operators


PHP Operators are used to perform operations on operands such as addition, subtraction etc.
for example :
        		     					    		
<?php
$number = 11 + 10;   // addition (+) operator
$number = 11 - 10;   // subtraction (-) operator
?>
        		     					    		
        		     					    	
In above example 11, 10 are operands and +,- are operators

php provides various operators.


Arithmetic Operators
arithmetic operators are used to perform mathematical operations on operands.

  • Operator
    Description
  • +
    Addition
  • -
    Subtraction
  • *
    Multiplication
  • /
    Division
  • %
    Modulus (remainder after division)
  • ++
    Increment by 1
  • --
    Decrement by 1

Assignment Operators
assignment operators are used to store values in variables.

  • Operator
    Description
  • =
    assign
  • +=
    assign with Add
  • -=
    assign with Subtract
  • *=
    assign with Multiply
  • /=
    assign with Divide
  • .=
    assign with Concat
  • %=
    assign with Modulo

Comparison Operators
comparison operators are used to compare variable values on both left and right side of operands.

  • Operator
    Description
  • ==
    is equal to
  • !=
    is not equal to
  • >
    is greater than
  • <
    is less than
  • >=
    is greter than or equal to
  • <=
    is less than or equal to
  • <>
    is not equal to
  • ===
    is both side equal and of same type
  • !==
    is both side not equal and not of same type

Logical Operators
logical operators are used to test values of variables on both left and right side of operands.

  • Operator
    Description
  • &&
    And
  • ||
    Or
  • and
    low precedence And
  • or
    low precedence Or
  • !
    not
  • xor
    exclusive or