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.

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 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 :

- In this line $d = date(”M”) specifies a variable that defines the month.
- 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 :
- 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 :

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