Floydian Posted August 15, 2008 Posted August 15, 2008 #-----------------------------------------# # iif function # # Why is not this in PHP beats me! # #-----------------------------------------# function iif($condition,$value_true="",$value_false="") { if($condition) return $value_true; else return $value_false; } I ran across this bit of code in a commercial php application. It's a simple function, and does what it's supposed to. BUT..... "Why is not this in php...." Well, it is in php. It's called a ternary operator.... $result = $condition ? $value_true : $value_false; And the egg is on their face! Quote
Guest Anonymous Posted August 15, 2008 Posted August 15, 2008 Re: PHP joke of the day... hehe - yep, seen that one... IIF() - that was in Clipper/dBase IIRC - so I guess it has it's roots in the late 70's early 80's. Although, I have to point out, that ternary ops do not always work as expected. There are some interesting ramifications of using them - especially with references. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.