Home » , , , , » IF-ELSEIF-ELSE Statement in PHP

IF-ELSEIF-ELSE Statement in PHP

Written By Unknown on Senin, 14 Desember 2009 | 01.42

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";
}
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger