PHP Conditional Statements

In this example, we will discuss php conditional statements. PHP supports the following conditional statements.

  • if conditional statement
  • if…..else conditional statement
  • if….elseif…..else conditional statement
  • switch…..case conditional statement

The if Statement

This is used to executed a block of code when the if condition is true.

if(condition){
    // Code to be executed
}

Example:

<?php 
    $d = date("D"); 
    if($d == "Fri"){     
    echo "Have a nice weekend!"; 
   } 
?>

Updated soon…

Leave a Reply