Home  >  Article  >  Backend Development  >  How to implement integer division judgment in php

How to implement integer division judgment in php

藏色散人
藏色散人Original
2020-07-11 09:20:035252browse

How to implement php integer division judgment: first create a php sample file; then define a variable; finally, judge whether the result is divisible according to the remainder operation, and the judgment statement is "if (! ($a % 5) && $a)".

How to implement integer division judgment in php

php method to determine divisibility:

Method 1: Judgment based on remainder operation

$a = 5
if (!($a % 5) && $a)
    echo $a."可以被5整除";

Method 2:

It’s OK to directly take the remainder to 0, $a%5==0.

For more related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to implement integer division judgment 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