Adam Hassan
Jan 8, 2020

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.

What are Php Arithmetic and Comparison Operators ?

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";

Thank you for reading the above article. Please let us know your comments below.
Subscribe to follow the next tutorial : How to Add Comments in Php Code >>>

References:

  • Practical Experience
About the author

Adam Hassan

Adam is a freelance web designer, recreational software developer, author and CEO of infoapper.com . Also, has passion to learn and transfer the know-how of every valuable thing.
Views: 26
0 Comment Guest
Recommend 0
Sort by Newest
Be the first to say something...

Ask Community

Ask questions and Share knowledge with Community

Find below recent posts for automation solutions with questions and answers by community. You can search in past threads or post new question about your assignment with detailed description, and always could mark your question as request. Sharing knowledge are highly appreciated by answering on others questions, and in return awards will be decided.

#
Recent Questions
*
i need to know how to convert 723,413,000 sq mm into mm2.
92
1
0
*
How to convert kg/m3 to kn/m3
48
1
0

  View More

× Close
Results: