Conditiional statement
<?php
$year = 2019;
if ($year % 400 == 0) {
   echo $year." is a leap year.";
} elseif ($year % 100 == 0) {
   echo $year." is not a leap year.";
} elseif ($year % 4 == 0) {
   echo $year." is a leap year.";
} else {
   echo $year." is not a leap year.";
}
?>
Using function
<?php
function leapyear($year) {
  if ($year % 400 == 0) {
     echo $year." is a leap year.";
  } elseif ($year % 100 == 0) {
     echo $year." is not a leap year.";
  } elseif ($year % 4 == 0) {
     echo $year." is a leap year.";
  } else {
     echo $year." is not a leap year.";
  }
}

leapyear(2019);
?>
by ვაჟა ტყემალაძე
2 years ago
PHP
Problem Solving
Note
php
Problem
PHP Object Oriented Programming (OOP)
0
Pro tip: use ```triple backticks around text``` to write in code fences