In this tutorial, I am going to explain php arithmetic and comparison operators. The php operators are the symbols used to allow the users to carry out various operations on variables.

**By the end of this tutorial you will be aware of:**

## Php Operators Types

The php operators are itemized into several types matching variables types, which could be summarized as follow:

## Php Arithmetic or Mathematical Operators on Php Numerical Variables:

#

Operation

Operator (Symbol) Method

*

Adding two variables

$x + $y

*

Subtracting two variables

$x - $y

*

Multiplicating two variables

$x * $y

*

Dividing two variables

$x / $y

*

Percentage of first out of second variables

$x % $y

*

Adding one to variable

$x++

*

Subtracting one from variable

$x--

*

Adding more than one to variable

$x+=n

*

Subtracting more than one from variable

$x-=n

## Php Comparison Operators on Php Various Type Variables:

#

Operation

Operator (Symbol) Method

*

Two equal variables

$x == $y

*

Two equal variables and of same type

$x === $y

*

Multiplicating two variables

$x * $y

*

Two unequal variables

$x != $y

*

Two unequal variables and not of same type

$x !== $y

*

First variable is less than the second variable

$x < $y

*

First variable is greater than the second variable

$x > $y

*

First variable is less than and equal to the second variable

$x <= $y

*

First variable is greater than and equal to the second variable

$x >= $y

## Other Php Operators on Php String Variables:

#

Operation

Operator (Symbol) Method

*

Concatenating or merging two php variables

$x .= $y

*

Declaring php variable from php string variable

$x = "y";

$$x = "value";

same as $y = "value";

$$x = "value";

same as $y = "value";

Thank you for reading the above article. Please let us know your comments below.

## References:

- Practical Experience

Views:
111

0 Comment
Guest

Recommend
0

Sort by Newest
Be the first to say something...

## Related Articles

## Latest Articles

- What are Php Arithmetic and Comparison Operators ? | Php Tutorial
- What are Php Variables and Types ? | Php Tutorial
- How to write your first php web page with code example | Php Tutorial
- Introduction to Php Learning Course | Php Tutorial
- How to Secure your JavaScript Code from being Copied by Competitors | Javascript Tutorial
- How to Promote JavaScript To Speed Your Website Loading Time For Higher SEO Performance | Javascript Tutorial