Know About The If...Else Statement in PHP


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
If...Else Statement

Related Posts:

  • Know About The If...Else Statement in PHP 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:- … Read More

0 comments:

Post a Comment

Recent Post

All Loop Types in PHP

Loops are used to execute a block of codes until a certain condition is met. The main benefit of using a loop is to save the time and effor...

Popular Posts