anantamu.com


PHP IF Statement


IF condition is true then it executes the code, It executes particular code at time.


IF Statement:

<?php  
$x = "Welcome";
IF($x == "Welcome")
{
echo " IF Yes!";
}
?>


IF and ELSE Statement:

IF statement conditon is true then It exectues the code otherwise It executes the else statement code.

Example

<?php  
$x = "Welcome";
IF ($x == "Welcome")
{
 echo " IF Yes!"; }
ELSE
{ echo " ELSE Yes!"; }
?>


IF and ELSE IF... ELSE Statement:

IF and ELSE IF... ELSE Statement - executes the codes for more than two conditions.

Example

<?php 
$x = "Welcome";
IF ($x == "Welcome")
{ echo " IF Yes!"; }
ELSE IF($x == "Good Morning")
{ echo  "Good Morning!"; }
ELSE IF($x == "Good Evening")
{ echo " ELSE IF Good Evening!"; }
ELSE
{ echo " ELSE Yes!"; }
?>