Use the IF-ELSEIF-ELSE statement to select one of several blocks of code to be executed.
Like a IF statement , an ELSEIF statement also contains a conditional statement without first having an IF statement.
When PHP evalutes the IF-ELSEIF-ELSE statement , it will first see if the IF statement is true. If that tests comes out false then it will check the first ELSEIF statement. If that is false it will either check the next ELSEIF statement, or if there are no more ELSEIF statements then, it will evaluate the ELSE statement...
Syntax:
if (condition)
{
codes to be executed if condition is true;
}
elseif (condition)
{
codes to be executed if condition is true;
}
else
{
codes to be executed if condition is false;
}
Example:
$name = "Kennedy";
if($name == "Lincoln")
{
echo "Good morning Lincoln";
}
elseif($name == "Bush")
{
echo "Good Morning Bush";
}
else
{
echo "Good Morning Everybody";
}
Monday, December 14, 2009
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment