Has anyone see this "iif" in php before? What is that actually? I try to search the documentation for it in php.net but I cant found any. Anyone can give a simple example of how to use this "iif"?
+1
A:
This is part of PHPKit. It stands for Immediate If.
The syntax is:
iif(condition, true statement, false statement);
@VolkerK's comment should be noted: "And keep in mind that iff(x,y,z) evaluates both y and z (no lazy function parameter evaluation in php) while x?y:z evaluates only y or z."
Skilldrick
2010-01-19 10:11:02
A:
The function iif
does not exist in the standard PHP libraries. But in most cases it is a 'short if statement' such as: (condition ? true : false)
.
Kolky
2010-01-19 10:11:38
That’s an expression and not a statement.
Gumbo
2010-01-19 10:15:49
And keep in mind that iff(x,y,z) evaluates both y and z (no lazy function parameter evaluation in php) while x?y:z evaluates only y or z.
VolkerK
2010-01-19 10:21:27
A:
copied from http://www.phpfreaks.com/forums/index.php?topic=124215.0
function iff($tst,$cmp,$bad) {
return(($tst == $cmp)?$cmp:$bad);
}
echo iff('one','two','three');
echo iff('four','four','ok');
Dyno Fu
2010-01-19 10:13:31