VOOZH about

URL: https://www.geeksforgeeks.org/php/how-to-use-modulo-operator-in-php/

⇱ How to use Modulo Operator in PHP ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to use Modulo Operator in PHP ?

Last Updated : 23 Jul, 2025

The modulo operator in PHP is represented by the percentage symbol %. It calculates the remainder of one number divided by another. The basic syntax for the modulo operator is-

Syntax:

$result = $num1 % $num2;

Here, $num1 is the dividend, and $num2 is the divisor. The result will be the remainder after dividing $num1 by $num2.

Example 1: This example describes the Basic Modulo Operation.


Output
Remainder is: 1



Example 2: This example checks for Even or Odd Numbers.


Output
7 is an odd number.



Comment
Article Tags: