« PHP Still Top Programming Language | Home | PHP Switch Statement »
Introducing ElseIf to your PHP
I’ve always been very indecisive when it comes to just about everything, so the option for an ‘elseif” in PHP runs right up my alley. Following our previous discussion on PHP IF Statements, the elseif introduces more options for your script to run with.
if ($a < $b) {
echo “$a is smaller than $b”;
}
elseif ($a == $b) {
echo “$a is equal to $b”;
}
else {
echo “Zach is still awesome”;
}
Please note there may be an unlimited amount of ElseIf statements in your code. With PHP you may write elseif or else if, and those working with C Language will see how this is similar. PHP will run both equally, even though the syntax is somewhat different. I personally would just use the one word, but that’s me.

