Monday, December 14, 2009

1:38 AM
Conditional statements are used to perform different actions based on different conditions.


The IF statement is necessary for most programming, thus it is important in PHP. In PHP we have the following conditional statements.. They are
IF Statement - Use this statement to execute some code only if a specified condition is true.
IF ... ELSE Statement - Use this statement to execute some code if a condition is true and another code if the condition is false.
IF...ELSEIF...ELSE Statement - Use this statement to select one of the several blocks of code to be executed.
SWITCH Statement - use this statement to select one of many blocks of code to be executed.


IF Statement : 


Use this statement to execute some code only if a specified condition is true.


Syntax:
if (condition) 
           {
              code to be executed if condition is true;
           }


Example:


$d=date("D");
if ($d=="Fri") 
{
echo "Have a nice weekend!";
}

0 comments: