Ternary Operator and the IIF function
The standard PHP If statement can be reduced by the ternary operator, which is described in the PHP manual Comparison Operators. The IIF function puts the ternary operator into a function.
Ternary Operator
conditional ? if_true : if_not_true;
is the same as
if (conditional)
{
if_true
}
else
{
if_not_true
}
IIF Function
To return the result of the ternary operator
function iif($expression, $returntrue, $returnfalse = '') {
return ($expression ? $returntrue : $returnfalse);
}
(1474)