Can a program have a few IFs and only one Else structures?
- by kwokwai
Hi all,
When I was doing some JQuery and PHP,
I noticed the If-else patterns were treated differently and varied from one language to another.
Say I got a simple input text field in a HTML
and I was using some Ifs and Elses to check the value input into the text field.
Text: <input type="text" name="testing"/>
In JQuery, I got some codes as follows:
if($("#testing").val()==1){
//do something
}
if($("#testing").val()=="add"){
//do something
}
else{
//do something
}
if($("#testing").val()=="hello"){
//do something
}
How come JQuery and PHP treated the Else statement differently?
I mean in JQuery, the third If statement was still proceeded even if it had gone to the Else statement,
but it stopped after the Else statement when I repeated the code in PHP script.