June 2005
Intermediate
720 pages
20h 6m
English
Conditionals, like variables, are integral to programming, and most people are familiar with them in some form or another. Dynamic Web pages, as you might imagine, frequently require the use of conditionals to alter a script’s behavior according to set criteria.
PHP’s three primary terms for creating conditionals are if, else, and elseif (which can also be written as two words, else if).
Every conditional includes an if clause:
if (condition) {
// Do something!
}
This in turn can become
if (condition) {
// Do something!
} else {
// Do something else!
}
and
if (condition1) { // Do something! } elseif (condition2) { // Do something else! } else { // Do something different! }
If a condition is true, the code in the ...
Read now
Unlock full access