Monday, February 22, 2010

MEL Lesson 3 Conditions

The below condition checks the value of the above variable and returns (produces a result) a message in the output window (accordingly).


//--------- Declare Variable --------------
$yourCharacter= "good";

//------------ Condition ------------------
if (
$yourCharacter == "good") {
print
"You are my friend";

} else {
print
"You are not my friend";

}


The below image illustrates what each line means



This condition can also have an additional "else if" added as below

if (
$yourCharacter == "good") {
print "You are my friend";
} else if
($yourCharacter == "bad") {
print "I prefer to ignore you";
} else {
print "You are not my friend";
}

No comments:

Post a Comment