Posted By

BilalELMoussaoui on 07/20/11


Tagged

php year leap


Versions (?)

check if the year is leap


 / Published in: PHP
 

check if the year is leap

  1. function is_leap($year){
  2. try {
  3. $year = intval(abs($year));
  4. if(is_numeric($year)){
  5. if(($year % 4) === 0){
  6. return true;
  7. }
  8. return false;
  9. }else{
  10. throw new Exception('is_leap() exepts one param as numeric given ,'.gettype($year));
  11. }
  12. }catch(Exception $e){
  13. trigger_error($e->getMessage(),E_USER_ERROR);
  14. }
  15. }

Report this snippet  

You need to login to post a comment.