mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
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:
parent
6d9eb33c6a
commit
3c669d7cee
1 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue