Adding ternary op wrapper function to basics

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4349 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-01-30 16:34:22 +00:00
parent 6d9eb33c6a
commit 3c669d7cee

View file

@ -1487,4 +1487,18 @@
return false;
}
}
/**
* Wraps ternary operations. If $condition is a non-empty value, $val1 is returned, otherwise $val2.
*
* @param mixed $condition Conditional expression
* @param mixed $val1
* @param mixed $val2
* @return mixed $val1 or $val2, depending on whether $condition evaluates to a non-empty expression.
*/
function ife($condition, $val1 = null, $val2 = null) {
if (!empty($condition)) {
return $val1;
}
return $val2;
}
?>