Home >Backend Development >PHP Problem >How to determine whether two numbers are remainder after division in php
php method to determine whether the division is remainder: 1. Use the "%" operator to calculate the division of two numbers and obtain the remainder value. The syntax is "Number 1% Number 2"; 2. Use the if statement and " !="operator can be used to determine whether the obtained remainder value is 0, the syntax is "if (remainder value!=0){//division has remainder}else{//division has no remainder}".
The operating environment of this tutorial: Windows 7 system, PHP version 7.1, DELL G3 computer
Determine whether the division is sufficient in PHP, or It is to determine whether the remainder of the division of two numbers is 0.
So we need to first use the "%" operator to find the remainder, and then use the "!=" or "==" operator to determine whether the remainder is 0.
Implementation code:
<?php header("Content-type:text/html;charset=utf-8"); $num1 = 12; $num2 = 3; $num=$num1%$num2; if($num!=0){ echo "相除有余"; }else{ echo "相除没有余"; } ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to determine whether two numbers are remainder after division in php. For more information, please follow other related articles on the PHP Chinese website!