php tutorial - PHP ifelse Condition - php programming - learn php - php code - php script




  • The ifelse expression executes some code if a condition is true, if condition is false PHP will execute the else statement.
 If Else Statement

Learn PHP - PHP tutorial - If Else Statement - PHP examples - PHP programs

php programming Syntax :

if (condition) 
{
   condition statement is true;
}
else 
{
    condition statement is false;
}
click below button to copy the code. php tutorial - team

php - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php syntax - php function - php if condition

php 7 Sample Code : sample php program

<!DOCTYPE html>
<html>
    <head>
        <title>ifelse-Condition</title>
    </head>
    <body>
        <?php
            $d = date("M");
            if($d == "May")
            {
                echo "Wikitechy Says This month is May!";
            } 
            else
            {
                echo "Wikitechy Says This month is not May";
            }
        ?>
    </body>
</html>
click below button to copy the code. php tutorial - team

php program Code Explanation :

Code Explanation for ifelse Condition In PHP

  1. In this line $d = date(”M”) specifies a variable that defines the month.
  2. If ($d == “May”) expression specifies that the current month is May. If the condition is true, PHP will execute statement” Wikitechy Says This month is May!”. If not then the else statement specifies condition as false, which execute the else statement “Wikitechy Says This month is not May”.

php coding Sample Output :

    output1 for ifelse Condition In PHP

  1. PHP statement executes the if condition by printing the echo statement “Wikitechy says this month is May!”. If the condition is false it goes to the else condition and prints the echo statements as shown below :

    output2 for ifelse Condition In PHP

  1. PHP statement executes else statement by printing the echo statement “Wikitechy says this month is not May”.


Related Searches to php ifelse Condition