If there is a posibilities that several condition is true, then use elseif statement. Below is syntax for elseif statement in PHP:-
if (condition)
Code1 with posible true condition;
elseif (condition)
Code2 with posible true condition;
else
code with posible true condition;
Example:-
Below example will output “Have a nice weekend!” if the current day is Friday, and “Have a nice Sunday!” if current day is Sunday. Otherwise it will output “Have a nice day!”.
<html>
<body>
<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
elseif ($d=="Sun")
echo "Have a nice Sunday!";
else
echo "Have a nice day!";
?>
</body>
</html>
![]() |
ElseIf Statement in PHP |
0 comments:
Post a Comment