How to use Modulo Operator in PHP ? Last Updated : 02 Jan, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. PHP <?php $dividend = 10; $divisor = 3; $result = $dividend % $divisor; echo "Remainder is: $result"; ?> OutputRemainder is: 1 Example 2: This example checks for Even or Odd Numbers. PHP <?php $number = 7; if ($number % 2 == 0) { echo "$number is an even number."; } else { echo "$number is an odd number."; } ?> Output7 is an odd number. Comment More infoAdvertise with us Next Article How to get negative result using modulo operator in JavaScript ? V vkash8574 Follow Improve Article Tags : PHP PHP-math Geeks Premier League 2023 Similar Reads Modulus Operator in Programming The modulus operator, often represented by the symbol '%', is a fundamental arithmetic operator used in programming languages to find the remainder of a division operation between two numbers. It returns the remainder of dividing the first operand by the second operand. Table of Content What is the 5 min read How to get negative result using modulo operator in JavaScript ? The %(modulo) operator in JavaScript gives the remainder obtained by dividing two numbers. There is a difference between the %(modulo) and the remainder operator. When remainder or %(modulo) is calculated on positive numbers then both behave similarly but when negative numbers are used then both beh 4 min read How to get negative result using modulo operator in JavaScript ? The %(modulo) operator in JavaScript gives the remainder obtained by dividing two numbers. There is a difference between the %(modulo) and the remainder operator. When remainder or %(modulo) is calculated on positive numbers then both behave similarly but when negative numbers are used then both beh 4 min read PHP 7 | Spaceship Operator This article will make you aware of a very useful operator i.e the spaceship operator PHP 7. The spaceship operator or combined comparison operator is denoted by "". This is a three-way comparison operator and it can perform greater than, less than and equal comparison between two operands. This ope 2 min read PHP 7 | Spaceship Operator This article will make you aware of a very useful operator i.e the spaceship operator PHP 7. The spaceship operator or combined comparison operator is denoted by "". This is a three-way comparison operator and it can perform greater than, less than and equal comparison between two operands. This ope 2 min read PHP | Bitwise Operators The Bitwise operators is used to perform bit-level operations on the operands. The operators are first converted to bit-level and then calculation is performed on the operands. The mathematical operations such as addition , subtraction , multiplication etc. can be performed at bit-level for faster p 5 min read Like