Arithmetic Operators
×
Home Courses Community Support
Arithmetic Operators

Operator in PHP is somethis that perform actions on variables and values. Operator receive one or more than one value and produce another value. Airthmethis operators are used for operation on numeric values. These operators are same as we used to use in mathmatics at school time.

Addition Operator (+)

This operator is used to sum the numeric values. See below example-

<?php
$X = 7;
$Y = 6;
$Z = $X+$Y;
echo $Z;
?>

Output:

13

In the above code, we have used two variables $X and $Y holding integer values. And another variable $Z hold the sum of $X and $Y.
 

Subtraction Operator (-)

This operator is used to substract the numeric values. See below example-

<?php
$X = 7;
$Y = 6;
$Z = $X-$Y;
echo $Z;
?>

Output:

1

 

Multiplication Operator (*)

This operator is used to multiply the numeric values. See below example-

<?php
$X = 7;
$Y = 6;
$Z = $X*$Y;
echo $Z;
?>

Output:

42

 

Division Operator (/)

This operator is used to divide the numeric values. See below code-

<?php
$X = 7;
$Y = 6;
$Z = $X/$Y;
echo $Z;
?>

Output:

1.1666666666667

enlightenedIn above code variable $Z return a float value.


Modulus Operator (%)

This operator is used to get the remainder value post division to a numeric value from another. See below example-

<?php
$X = 7;
$Y = 6;
$Z = $X%$Y;
echo $Z;
?>

Output:

1

← Preview

Other Data Types

Next →

Increment and Decrement Operators

NOTES

Our mission is to provide highly effective and quality education via innovative solutions. Geeksdemy look forward to bridge the gap between in-demand technology and academics in order to deliver innovative, easy, interesting and affordable learning across the Globe.

Courses

  • Python
  • Game Development with Unity 3D
  • Arduino
  • PCB & Circuit Designing
  • Robotics and Embedded C
  • 8051/8052 Embedded Systems
  • QuadCopter & UAV
  • MATLAB with Robotics
  • Raspberry Pi
Learn On the Go!
Get the Android App
Get the iOS App