In php there are 6 arithmetic operators

In php there are 6 arithmetic operators

Introduction to Arithmetic Operators in PHP

Arithmetic operators are one of the types of operators in the PHP programming language. The arithmetic operators are very useful to many mathematical calculations to do different types of programs to ease our problem-solving tasks. Arithmetic operators can be used only with the numerical values/numbers to perform arithmetic operations like Addition (+), Subtraction (-), Multiplication (x), Division (/), Modulus (%), Exponentiation (**)(1st number to the power of 2nd number ).

Explanation of Arithmetic operators in PHP

The Arithmetic operators are used two numeric values/numbers to perform Addition (+), Subtraction (-), Multiplication (x), Division (/), Modulus (%), Exponentiation (**)(1st number to the power of 2nd number ).

1. Addition (+)

The addition is one of the Arithmetic operators of the PHP programming language. It requires at least two/ more numerical values/numbers to add.

Code:

<?php
$pavan = 25;
$kumar = 24;
$sake = $pavan + $kumar;
echo "First Variable Value : $pavan";
echo "<br/>";
echo "Second Variable Value : $kumar";
echo "<br/>";
echo "The sum of the two variables :: ";
echo $sake;
echo "<br/>";
echo "<hr/>";
$p1 = 23;
echo "Third Variable Value : $p1";
echo "<br/>";
$k1 = $sake + $p1 ;
echo "The Sum of the three Variables :: $k1";
echo "<br/>";
echo "<hr/>";
$pavan1 = 44;
echo "Fourth Variable Value : $pavan1";
echo "<br/>";
$s1 = $pavan1 + $k1;
echo "The Sum of the four Variables :: $s1";
echo "<br/>";
?>

Output:

In php there are 6 arithmetic operators

2. Subtraction (-)

Subtraction is one of the Arithmetic operators of the PHP programming language. It requires at least two/ more numerical values/numbers to subtract.

Code:

<?php
$pavan = 25;
$kumar = 24;
$sake = $pavan - $kumar;
echo "First Variable Value : $pavan";
echo "<br/>";
echo "Second Variable Value : $kumar";
echo "<br/>";
echo "The substraction of the two variables :: ";
echo $sake;
echo "<br/>";
echo "<hr/>";
$p1 = 23;
echo "Third Variable Value : $p1";
echo "<br/>";
$k1 = $sake - $p1 ;
echo "The Substraction of the three Variables :: $k1";
echo "<br/>";
echo "<hr/>";
$pavan1 = 44;
echo "Fourth Variable Value : $pavan1";
echo "<br/>";
$s1 = $k1 - $pavan1;
echo "The Substraction of the four Variables $pavan, $kumar, $p1, $k1, $pavan1 :: $s1";
echo "<br/>";
?>

Output:

In php there are 6 arithmetic operators

3. Multiplication (x)

Multiplication is one of the Arithmetic operators of the PHP programming language. It requires at least two/ more numerical values/numbers to multiply.

Code:

<?php
$pavan = 25;
$kumar = 24;
$sake = $pavan * $kumar;
echo "First Variable Value : $pavan";
echo "<br/>";
echo "Second Variable Value : $kumar";
echo "<br/>";
echo "The multiplicaation of the two variables :: ";
echo $sake;
echo "<br/>";
echo "<hr/>";
$p1 = 23;
echo "Third Variable Value : $p1";
echo "<br/>";
$k1 = $sake * $p1 ;
echo "The Multiplication of the three Variables :: $k1";
echo "<br/>";
echo "<hr/>";
$pavan1 = 44;
echo "Fourth Variable Value : $pavan1";
echo "<br/>";
$s1 = $pavan1 * $k1;
echo "The Multiplication of the four Variables :: $s1";
echo "<br/>";
?>

Output:

In php there are 6 arithmetic operators

4. Division (/)

The division is one of the Arithmetic operators of the PHP programming language. It requires at least two/ more numerical values/numbers to divide.

Code:

<?php
$pavan = 250;
$kumar = 5;
$sake = $pavan / $kumar;
echo "First Variable Value : $pavan";
echo "<br/>";
echo "Second Variable Value : $kumar";
echo "<br/>";
echo "The Division of the two variables :: ";
echo $sake;
echo "<br/>";
echo "<hr/>";
$p1 = 5;
echo "Third Variable Value : $p1";
echo "<br/>";
$k1 = $sake / $p1 ;
echo "The Division of the three Variables :: $k1";
echo "<br/>";
echo "<hr/>";
$pavan1 = 5;
echo "Fourth Variable Value : $pavan1";
echo "<br/>";
$s1 = $k1/$pavan1;
echo "The Division of the four Variables :: $s1";
echo "<br/>";
?>

Output:

In php there are 6 arithmetic operators

5. Modulus (%)

Modulus is one of the Arithmetic operators of this programming language. It requires at least two/ more numerical values/numbers to know the remainder value. You will get only number 1 or number 0 values as the remainder when you divide a number with any other number, but if you divide with the big number, you will definitely get 0 value for that.

Code:

<?php
$pavan = 250;
$kumar = 5;
$sake = $pavan % $kumar;
echo "First Variable Value : $pavan";
echo "<br/>";
echo "Second Variable Value : $kumar";
echo "<br/>";
echo "The remainder by dividing $pavan with $kumar :: ";
echo $sake;
echo "<br/>";
echo "<hr/>";
$p1 = 3;
echo "Third Variable Value : $p1";
echo "<br/>";
$k1 = $pavan%$p1 ;
echo "The remainder by dividing $pavan with $p1 :: $k1";
echo "<br/>";
echo "<hr/>";
$pavan1 = 5;
echo "Fourth Variable Value : $pavan1";
echo "<br/>";
$s1 = $pavan%$pavan1;
echo "The remainder by dividing $pavan with $pavan1 :: $s1";
echo "<br/>";
?>

Output:

In php there are 6 arithmetic operators

6. Exponentiation (**)

Exponentiation is one of the Arithmetic operators of this programming language. It requires at least two/ more numerical values/numbers to know the 1st number to the power of the 2nd number.

Code:

<?php
$pavan = 2;
$kumar = 5;
$sake = $pavan ** $kumar;
echo "First Variable Value : $pavan";
echo "<br/>";
echo "Second Variable Value : $kumar";
echo "<br/>";
echo "The result by getting the power of $pavan with $kumar :: ";
echo $sake;
echo "<br/>";
echo "<hr/>";
$p1 = 3;
echo "Third Variable Value : $p1";
echo "<br/>";
$k1 = $pavan**$p1 ;
echo "The result by getting the power of $pavan with $p1 :: $k1";
echo "<br/>";
echo "<hr/>";
$pavan1 = 5;
echo "Fourth Variable Value : $pavan1";
echo "<br/>";
$s1 = $pavan**$pavan1;
echo "The result by getting the power of $pavan with $pavan1 :: $s1";
echo "<br/>";
?>

Output:

In php there are 6 arithmetic operators

Conclusion

I hope you understood what the Arithmetic operators are and how to use those Arithmetic operators. I think you also understood what is meant by Addition (+), Subtraction (-), Multiplication (x), Division (/), Modulus (%), Exponentiation (**)(1st number to the power of 2nd number ).

This is a guide to Arithmetic Operators in PHP. Here we discuss the detail explanation of arithmetic operators with code implementation. You can also go through our suggested articles to learn more –

  1. Control Statement in PHP
  2. SQL Arithmetic Operators
  3. PHP include_once
  4. PHP GET Method

How many arithmetic operators are there in PHP?

Description. There are five basic arithmetic operators.

What are the six arithmetic operators?

7.1. The arithmetic operators for scalars in MATALB are: addition (+), subtraction (−), multiplication (*), division (/), and exponentiation (^).

What are different arithmetic operators in PHP?

PHP Operators.

What are the 7 arithmetic operators?

Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication and division..
Addition..
Subtraction..
Multiplication..
Division..
Modulus..
Exponentiation..
Floor division..