在PHP中,判断一个年份是否为闰年通常遵循以下规则:

1. 如果年份能被4整除且不能被100整除,则是闰年。

实例判断闰年php,PHP实例判断闰年方法详解  第1张

2. 如果年份能被400整除,则也是闰年。

以下是一个PHP代码实例,用于判断一个年份是否为闰年:

```php

function isLeapYear($year) {

if (($year % 4 == 0 && $year % 100 != 0) || $year % 400 == 0) {

return true;

} else {

return false;

}

}

// 测试年份

$testYears = [2000, 2001, 2004, 1900, 2100];

// 输出结果

foreach ($testYears as $year) {

echo "