fork download
  1. <?php
  2. function isLeapYear($year = NULL) {
  3. $year = is_numeric($year) ? $year : date('Y');
  4. return cal_days_in_month(CAL_GREGORIAN, 2, $year) === 29;
  5. }
  6.  
  7. var_dump(isLeapYear());//Ano atual
  8. var_dump(isLeapYear(2015));//Ano 2015
  9. var_dump(isLeapYear(2016));//Ano 2016
  10. var_dump(isLeapYear(2017));//Ano 2017
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
bool(true)
bool(false)
bool(true)
bool(false)