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](https://www.wikitechy.com/php/img/php-images/if-statement.gif)
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](https://www.wikitechy.com/php/img/php-images/php-if-condition.png)
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 Code Explanation for if Condition In PHP](https://www.wikitechy.com/php/img/php-images/code-explanation-php-if-condition.png)
- In PHP, $t = date(‘’y”) is a variable that defines the Year (Note: In similar way date(“h”) defines hours, date(“w”) defines week).
- 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 output for if Condition In PHP](https://www.wikitechy.com/php/img/php-images/output-for-php-if-condition.png)
- Here the PHP statement executes the if condition by printing the echo statement “Wikitechy says this year is 2016”.