check if the year is leap


/ Published in: PHP
Save to your folder(s)

check if the year is leap


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.