Discuss why PHP is present in both ElseIf and else if

Source: Internet
Author: User
Tags parse error
Discuss why PHP has both ElseIf and else if
these words are in the PHP manual, I am more curious about why PHP will exist at the same time these two ways?
ElseIf, as implied by this name, is the combination of if and else. As with else, it extends the IF statement and can execute a different statement if the original if expression has a value of false. However, unlike else, it only executes the statement when the conditional expression value of ElseIf is true. For example, the following code will display a is bigger than b,a equal to B or a is smaller than b according to the conditions:
if ($a > $b) {
echo "A is bigger than B";
} elseif ($a = = $b) {
echo "A is equal to B";
} else {
echo "A is smaller than B";
}
?>

There can be multiple ElseIf statements in the same if structure. The ElseIf statement (if any) with the first expression value of TRUE will be executed. In PHP, you can also write "else if" (two words), which behaves exactly like "ElseIf" (a word). There is a slight difference in the meaning of syntactic analysis (which is the same behavior if you are familiar with C language), but the bottom line is that both produce exactly the same behavior.

The ElseIf statement is executed only if the expression value of the previous if or ElseIf is FALSE, and the current ElseIf expression evaluates to TRUE.

Note: It must be noted that ElseIf and else if the braces are used only in cases similar to the one in the previous example, note that ElseIf and else if will is considered exactly the Same when using curly brackets as in the above example. When using a colon to define your if/elseif conditions, you must not separate else if into the words, or PHP would fail wit H a parse error.

------Solution--------------------
I don't think it means much to discuss this question.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.