Know if a number n / 4 gives PHP integer

2

I've done this:

$year=2016  
if(($year%4)==1){
    ...
}

I would like to know if a number divided by 4, its result is whole, that is to say.

2016/4 = 504, therefore it would enter the if.

    
asked by Kiku S. 28.05.2017 в 11:15
source

1 answer

2

It's just like you're doing it, but changing the value of the comparison.

$year=2016  
if(($year%4)==0){
    ...
}

The % operator returns the remainder of the division. If the division is exact (no remainder), returns 0 .

    
answered by 28.05.2017 / 11:20
source