If Control Structure

Today I'm putting together a chart for the "if" control structure. The chart is intended for developers who program in php, vbscript, and javascript. Its easy to get the syntax wrong when you program with all three scripting languages.

"If"

php if (condition) {
     statements;
}
javascript if (condition) {
     statements
}
vbscript if (condition) then statement 1 : statement 2

or

if (condition) then
     statements
end if

"Else"

php if (condition) {
     statements;
} else {
     statements;
}
javascript if (condition) {
     statements
} else {
     statements
}
vbscript if (condition) then
     statements
else
     statements
end if

"ElseIf"

php if (condition) {
     statements;
} elseif (condition 2) {
     statements;
} else {
     statements;
}
javascript elseif not available
vbscript if (condition) then
     statements
elseif (condition 2) then
     statements
else
     statements
end if

References

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>