Application Architecture : Miscellaneous
Quick If
Submitted By: Amit AroraDate: 08/21/01 18:15
Sometimes, while working in the HTML you need to print or manipulate a string, based upon certain values (mostly boolean). You could use
if (...) {
...
}
else {
...
}How about this ....
function iif( $bool = true, $tstr = '', $fstr = '')
{
if ($bool)
{
return( $tstr );
}
else
{
return( $fstr );
}
}
I have used strings as return value, you may use integers or even abstract return value, depending on your need.
A example:
echo iif( $loggedin, "Logged In", "Not Logged In" );
Any suggestions, comments are welcome ...
| Comments: | ||
| Re: Quick If | biggus | 08/30/01 10:03 |
| Better solution already exists in PHP | Ryan Holmes | 08/29/01 18:52 |
| quick IF | Seb Frost | 08/28/01 15:26 |
| PHP Built in Functions | Josh B | 08/23/01 09:01 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly. | ||

