Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this "iif" in php means?

Tags:

syntax

php

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"?

like image 760
mysqllearner Avatar asked Jan 19 '10 10:01

mysqllearner


2 Answers

The function iif does not exist in the standard PHP libraries. But in most cases it is a 'short if expression' such as: (condition ? true : false).

like image 165
Kolky Avatar answered Oct 04 '22 00:10

Kolky


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');

like image 41
Dyno Fu Avatar answered Oct 03 '22 23:10

Dyno Fu