PHP arithmetic operators

When you were start your first math learning, I am sure you have used + sign, - sign, * and / sign. These sign are used in PHP as a arithmetic operator. Different kinds of PHP arithmetic operators are + operator, - operator, * multiply operator, / division operator, % modulus operator. Here we describe its clearly.

(+) Addition Operator: Using this operator we can add two value such that $a + $b or 12+15=27.
(-) Subtraction Operator: Using this operator we can subtract two value such that $a - $b.
(*) Multiply Operator: We call * sign is multiply operator in PHP. Multiply operator is used for multiplication such that 12*2=24.
(/) Division Operator: To find quotient we use PHP division operator. For an example, 12/2=6.
(%) Modulus Operator: We find remainder from two variable we use PHP modulus operator. For an example, 12%2=0.

PHP Arithmetic Operator Example:  Let's try an example where we have used all PHP arithmetic operators.
<?php
echo (2+8); // Addition
echo "<br>";
echo (9-3); // Subtraction
echo "<br>";
echo (2*9); // Multiplication
echo "<br>";
echo (6/2); // Division
echo "<br>";
echo (6%2); // Modulus Operation
?>
The outputs are 10,6,18,3,0. Try to change our code and see what will be the output.

Comments

Popular posts from this blog

How to show only month and year fields in android Date-picker?

How to construct a B+ tree with example

Conflict Serializability in database