Displaying even numbers in PHP

Testing for even numbers

A number is even when the remainder after division by 2 is zero. The modulus operator % is the simplest test.

2
4
6
8
10
12
14
16
18
20
for(\21=1;\21<=20;\21++){
if(\21 % 2 ==0){
echo \21;
echo '<br>'; // Line break
}
}

fmod()
All Basic Codes


Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer