If and else if in PHP, colon style

后端 未结 1 517
臣服心动
臣服心动 2021-02-07 10:45

One function of PHP that I like to use is the colon-style if statement (I don\'t know what it\'s actually called.)


    

        
1条回答
  •  遥遥无期
    2021-02-07 11:42

    I was able to get it to work.

    In this very specific case, else if is not synonymous with elseif.

    Substituting elseif for else if fixes the issue.

    
        
    
        
    
    

    From PHP.net:

    Note: Note that elseif and else if will only be 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 two words, or PHP will fail with a parse error.

    0 讨论(0)
提交回复
热议问题