If else embedding inside html

前端 未结 5 1534
情话喂你
情话喂你 2020-12-12 15:35

What is the correct way of embedding if else and elseif conditions inside html?

5条回答
  •  北海茫月
    2020-12-12 16:04

    In @Patrick McMahon's response, the second comment here ( $first_condition is false and $second_condition is true ) is not entirely accurate:

    
      /*$first_condition is true*/
      
    First Condition is true
    /*$first_condition is false and $second_condition is true*/
    Second Condition is true
    /*$first_condition and $second_condition are false*/
    Conditions are false

    Elseif fires whether $first_condition is true or false, as do additional elseif statements, if there are multiple.

    I am no PHP expert, so I don't know whether that's the correct way to say IF this OR that ELSE that or if there is another/better way to code it in PHP, but this would be an important distinction to those looking for OR conditions versus ELSE conditions.

    Source is w3schools.com and my own experience.

提交回复
热议问题