May 2003
Intermediate to advanced
592 pages
14h 28m
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 based upon set criteria.
PHP’s three primary terms for creating conditionals are if, else, and elseif.
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 else!
}
If a condition is true, the code in the following curly braces ({}) will be executed. If not, ...
Read now
Unlock full access