Code
/**
* Checks if $var is already defined and if not, sets it to
* $default.
*
* @param $var Variable to check.
* @param $default Value to give the checked variable if
* found to be null; "" by default.
* @param $catchNulls TRUE: treat empty strings as null; FALSE
* by default.
*
* @note It's a lot like ColdFusion's <CFPARAM> tag.
*/
function set_default(&$var, $default="", $catchNulls=FALSE) {
if (!isset($var) || ($catchNulls && $var == "")) {
$var = $default;
}
}
