Modulus of Number in PHP With Example Program

Modulus of Number in PHP With Example Program. A simple Php program to print the modulus of the number. Using this program we can print the modulus of the number. The modulus operation is used in mathematics to obtain the residual of division between two numbers. A modulo is the remainder of the Euclidean division of x by y (x/y) given two positive numbers, the dividend (x) and the divisor (y).

<?php
$x = 5;
$y = 4;
echo $x % $y;
?>

 

Output:

1

Modulo Operator in Php

Modulo is an integer operator, it transforms both operands to integers before computing the remainder. The sign of the dividend determines the sign of the value returned by a modulo operation. When dividing two negative integers, the outcome will be a positive number. The modulo operation in computing yields the remainder or signed remainder of a division after one integer is divided by another, which is known as the modulus of the operation.