Monday, January 25, 2021
Home PHP PHP Lessons PHP Lesson 3: Arithmetic Operators

# PHP Lesson 3: Arithmetic Operators

In PHP Lesson 3: Arithmetic Operators we will be studying the PHP support for mathematical operations. Arithmetic Operators are used to perform certain mathematical operations like Addition, Subtraction, Multiplication, Division, Modulus and so on. PHP also provides support for calculating logarithms, square roots through functions.

Lets perform some basic mathematical operations using PHP Arithmetic Operators.

Consider the below script, which performs all basic 5 arithmetic operations.

```
<?php

\$a = 20;
\$b = 5;

\$sum = \$a + \$bÂ  //Result will 20 + 5 = 25

//Subtraction
\$sub = \$a - \$b //Result will be 20 - 5 = 15

//Multiplication
\$mul = \$a * \$b //Result will be 20 * 5 = 100

//Division
\$div = \$a / \$b //Result will be 20 / 5 = 4

//Remainder or Modulus
\$rem = \$a % \$b //Result will be 20 % 5 = 0 as there is no remainder out of 20 / 5

?>

```

In the above example we have used all basic five Arithmetic Operators and you can see these are simple and basic.Â  The modulus or remainder operator is used to get the remainder of a division operation for example 10 divided by 3 remainder is 1.

In this PHP Lesson 3, we have studies PHP Arithmetic Operators, in the next lesson we will be studying other operators like Assignment Operators, Increment / Decrement Operators, Comparison Operators etc etc.

### Android Webview Tutorial With Example | How to Use Webview in Android

Android Webview Tutorial With Example Have you seen anÂ Android app displaying Web content using Webview. This Android Webview Tutorial is about integratingÂ Webview using Android Studio....

### Student Registration Project in PHP

In this Student Registration Project we are providing a form in simple html to the student and that form sends the data to "student.php"...

### Java GUI Calculator Source Code

Here we have aÂ Java GUI Calculator Source Code for you in which aÂ Java GUI calculator has been created usingÂ "swing" and "awt". The calculator has...

### Numeric Array in PHP

Numeric arrays can store numbers, strings and any object but their index will be represented by numbers. By default array index starts from zero....