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




  • The php “if condition “specifies the if expression in terms of Boolean value.
  • If the expression evaluates to be TRUE, PHP will execute its statement.
 If Statement

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

php programming Syntax :

if (condition) 
{
   condition statement is true;
}
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

learn php Sample Code : sample php program

<!DOCTYPE html>
<html>
    <head>
        <title>if-Condition</title>
    </head>
    <body>
        <?php
            $t = date("y");
            if ($t > "2016") 
            {
                echo "Wikitechy says this year is 2016";
            }
        ?>
    </body>
</html>
click below button to copy the code. php tutorial - team

php for beginners Code Explanation :

Code Explanation for if Condition In PHP

  1. In PHP, $t = date(‘’y”) is a variable that defines the Year (Note: In similar way date(“h”) defines hours, date(“w”) defines week).
  2. Here, if ($t > “2016”) expression specifies the current year is less than 2016 condition, which executes the PHP statement” “Wikitechy says this year is 2016”.

php coding Sample Output :

output for if Condition In PHP

  1. Here the PHP statement executes the if condition by printing the echo statement “Wikitechy says this year is 2016”.


Related Searches to php if Condition