Press "Enter" to skip to content

phpArithmeticOperators

PHP Arithmetic Operators

PHP Arithmetic Operators  perform basic mathematical functions.
 
Operator NameExample
addition operator (+)2+2 output 4
subtraction operator (-)4-1 output  3
division operator (/)10/2 output 5
modulus operator (%)3*2 output 6
multiplication operator (*)

3*2 output 6

Logical OperatorsAnd or &&,or or ||,Xor
String Operators

 .(Dot)

Example for PHP Arithmetic Operators


<?php
$n=40;
$m=20;
$total=$n+$m; //addition
echo “Addition of two Number:$total<br />”;
$total=$n-$m; //subtraction
echo “Subtraction of two Number:$total <br />”;
$total=$n*$m; // multiplication
echo “Multiplication of two Number:$total<br />”;
$total=$n/$m; //division
echo “Division of two number:$total”;
?>