zoukankan      html  css  js  c++  java
  • php中的elseif和else if

    以前的时候还没注意到,知道进入公司,看的代码多了点,时常看到elseif的分支,而我自己时常用的是else if,于是就注意到,他们既然都可以用,那么他们的却别在哪儿呢?

    通过查询,原来,确实有点小小区别:1.一个能用冒号,另外一个不可以

    <?php
    /* Incorrect Method: */
    if($a > $b):
        echo $a." is greater than ".$b;
    else if($a == $b): // Will not compile.
        echo "The above line causes a parse error.";
    endif;
    /* Correct Method: */
    if($a > $b):
        echo $a." is greater than ".$b;
    elseif($a == $b): // Note the combination of the words.
        echo $a." equals ".$b;
    else:
        echo $a." is neither greater than or equal to ".$b;
    endif;
    ?>
    持之以恒!
  • 相关阅读:
    小数的进制转换
    水题 O
    水题 J
    水题T,二进制转16进制
    水题B
    水题C
    HDU 2042
    HDU 2041
    Index For SQL Server
    Learning Note For Angular
  • 原文地址:https://www.cnblogs.com/ishenghuo/p/4350383.html
Copyright © 2011-2022 走看看