search
HomeBackend DevelopmentPHP ProblemHow 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}".

How to determine whether two numbers are remainder after division in php

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 "相除没有余";
}
?>

How to determine whether two numbers are remainder after division in php

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools