Tutorialsplane

PHP Operators


PHP Operators:–Operators are oftenly used in programming languages statements. Hence operators are useful to perform operations on various variables.


PHP Operators | Example

There are several operators defined in php language which are listed below as follows:-

  1. Assignment operators
  2. Increment/Decrement operators
  3. Arithmetic operators
  4. Comparison operators
  5. Logical operators
  6. Array operators
  7. String operators

ArithMetic Operators Types | Example

Let us understand few of them with examples-There are six following arithmetic operators in php. Following table is an example which easily describes all arithmetic operators in brief.

 

Operator Symbol Name Example Meaning
Substraction $x-$y Difference of two numbers
* Multiplication $x*$y Multiplication of two numbers
/ Division $x*$y Division of two numbers
% Modulus $x%$y Modulus of two numbers
** Exponentiation $x**$y EResult after raising $x to the $y’th power
* Multiplication $x*$y Multiplication of two numbers

 

Comparison Operators Types | Example

These operators are used to compare values. Below table represents their usage in php. 

 

Operator Symbol Name Example Meaning
!= Not equal $a != $b Returns true if $x is not equal to $y
<> Not equal $a<>$b Returns true if $x is not equal to $y
!== Not identical a!==$b True if $x is not equal to $y, or they are not of the same type
=== Identical $a===$b Returns true if $x is equal to $y, and they are of the same type
== Equal $a==$b Returns true if $x is equal to $y
> Greater than $a>$b eturns true if $x is greater than $y
< Less than $a<<$b Returns true if $x is less than $y
<= Less than or equal to $a<=$b Returns true if $x is less than or equal to $y
>= Greater than or equal to $a>=$b Returns true if $x is greater than or equal to $y

 

PHP Tutorial