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
Related Posts
IF...ELSE Statement in PHP
14 December 2009Learnphp0IF Statement in PHP
14 December 2009Learnphp0Switch statements in PHP
14 December 2009Learnphp0Facebook Live Chat using PHP and Javascript
25 November 2015Learnphp20
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment