Jump to content

PHP joke of the day...


Recommended Posts

# iif function                            #
# Why is not this in PHP beats me!        #
function iif($condition,$value_true="",$value_false="")
      return $value_true;
      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.


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

Link to comment
Share on other sites

Guest Anonymous

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...