Learn PHP for Developing Web Application

Learn to build web applications with PHP and MySQL, Start your own blog, e-commerce site. In this tutorial you will learn basic, syntax, examples, functions, loops, cookies, sessions, file handling, data connectivity, etc.

PHP Operators


PHP Operator is a symbol i.e used to perform operations on operands. For example:

$num=30+50;//+ is the operator and 30,50 are operands

In the above example, + is the binary + operator, 30 and 50 are operands and $num is variable.

PHP Operators can be categorized in following forms:

  • Arithmetic Operators
  • Comparison Operators
  • Bitwise Operators
  • Logical Operators
  • String Operators
  • Incrementing/Decrementing Operators
  • Array Operators
  • Type Operators
  • Execution Operators
  • Error Control Operators
  • Assignment Operators

We can also categorize operators on behalf of operands. They can be categorized in 3 forms:

  • Unary Operators: works on single operands such as ++, -- etc.
  • Binary Operators: works on two operands such as binary +, -, *, / etc.
  • Ternary Operators: works on three operands such as "?:".

PHP Operators Precedence

Let's see the precedence of PHP operators with associativity.

OperatorsAdditional InformationAssociativity
clone newclone and newnon-associative
[array()left
**arithmeticright
++ -- ~ (int) (float) (string) (array) (object) (bool) @increment/decrement and typesright
instanceoftypesnon-associative
!logical (negation)right
* / %arithmeticleft
+ - .arithmetic and string concatenationleft
<< >>bitwise (shift)left
< <= > >=comparisonnon-associative
== != === !== <>comparisonnon-associative
&bitwise ANDleft
^bitwise XORleft
|bitwise ORleft
&&logical ANDleft
||logical ORleft
?:ternaryleft
= += -= *= **= /= .= %= &= |= ^= <<= >>= =>assignmentright
andlogicalleft
xorlogicalleft
orlogicalleft
,many uses (comma)left