Home >> PHP - MySQL Programming with PHP 2.1 [Page 4] Article by: Shelton Manage Tuesday, 26th May, 2009
Conditionals and Operators
Conditionals, like variables. PHP's three primary terms for creating conditionals are if, else and elseif. Every conditional includes and if cluse.
if (condition) {
// Do Something
}
This in turn can become
if (condition) {
// Do Something
} else {
//Do Somthing else!
}
and
if (condition) {
// Do Something
} elseif {
//Do Somthing else!
} else {
//Do Somthing else!
}
It's this important that the else always comes last and is treaded as the default action unles specific critaria (the conditions) are met. A condition can be TRUE in PHP for any number of reasons, there are commom true conditiuons:
- $var, if $var has a value other than 0, an empty string, or NULL
- isset($var), if $var has any value other than NULL, including 0 and empty string
- TRUE
Page: First - 1 2 3 4 5 6 7 8 9 10 - Last
|
|