If one condition is true and another is false then if else statement is used.
Below is syntax:-
If (Condition)
Code with true condition;
Else
Code with false condition;
Example:-
<html>
<body>
<?php
$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
else
echo "Have a nice day!";
?>
</body>
</html>
This example will output “Have a nice weekend!” if the current day is Friday, otherwise it will output “Have a nice day!”.
![]() |
If...Else Statement |
0 comments:
Post a Comment