<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: iif function</title>
	<link>http://www.phpit.net/code/iif-function/</link>
	<description>PHPit has dozens of PHP articles, codesnippets and FAQ's.</description>
	<pubDate>Fri, 16 May 2008 07:54:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>

	<item>
		<title>by: Jason</title>
		<link>http://www.phpit.net/code/iif-function/#comment-2685</link>
		<pubDate>Thu, 25 May 2006 07:05:38 +0000</pubDate>
		<guid>http://www.phpit.net/code/iif-function/#comment-2685</guid>
					<description>One last thought: there are cases where an operator might be preferred over a function, and vice versa.

Functions will evaluate all arguments before executing, and ?: will perform short-circuit evaluation... this can lead to some unexpected behaviour if the arguments returntrue and returnfalse are actually the results of other function calls.

It's best to plug the following code in and see the difference for yourself.

</description>
		<content:encoded><![CDATA[<p>One last thought: there are cases where an operator might be preferred over a function, and vice versa.</p>
<p>Functions will evaluate all arguments before executing, and ?: will perform short-circuit evaluation&#8230; this can lead to some unexpected behaviour if the arguments returntrue and returnfalse are actually the results of other function calls.</p>
<p>It&#8217;s best to plug the following code in and see the difference for yourself.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Jason</title>
		<link>http://www.phpit.net/code/iif-function/#comment-2683</link>
		<pubDate>Thu, 25 May 2006 06:45:47 +0000</pubDate>
		<guid>http://www.phpit.net/code/iif-function/#comment-2683</guid>
					<description>In response to Gaurav:

Err, VB.NET *does* have an Iif function (look in Microsoft.VisualBasic), and it isn't just a holdover from the pre-.NET days either - there's just no other way unlike the ?: operator which exists in the C-like languages (C, C++, C#, Java, etc.). Additionally, VBA uses IIf (this shouldn't be a surprise, since VBA is a subset of VB) which means all your Office automation products, and SQL typically has IIf and CASE function equivalents in each of its many flavours (MSAccess, MSSQL, mySQL, Oracle, etc.)

Other than that, I agree - it can be argued that the ?: operator *is* the equivalent of an Iif function - and thus you don't need to write your own function... the only reason I can think up is that of making code easier to read to the untrained eye.</description>
		<content:encoded><![CDATA[<p>In response to Gaurav:</p>
<p>Err, VB.NET *does* have an Iif function (look in Microsoft.VisualBasic), and it isn&#8217;t just a holdover from the pre-.NET days either - there&#8217;s just no other way unlike the ?: operator which exists in the C-like languages (C, C++, C#, Java, etc.). Additionally, VBA uses IIf (this shouldn&#8217;t be a surprise, since VBA is a subset of VB) which means all your Office automation products, and SQL typically has IIf and CASE function equivalents in each of its many flavours (MSAccess, MSSQL, mySQL, Oracle, etc.)</p>
<p>Other than that, I agree - it can be argued that the ?: operator *is* the equivalent of an Iif function - and thus you don&#8217;t need to write your own function&#8230; the only reason I can think up is that of making code easier to read to the untrained eye.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Gaurav</title>
		<link>http://www.phpit.net/code/iif-function/#comment-1716</link>
		<pubDate>Sat, 13 May 2006 17:35:03 +0000</pubDate>
		<guid>http://www.phpit.net/code/iif-function/#comment-1716</guid>
					<description>Why do we need it when a simple ternary operator already exists...

Also, would like to know which of the "most languages" have the iif function?

PHP: No
C: No
C++: No
PERL: No
Python: No
Java: No
C#: No
Visual Basic .Net: No
J#: No

Or am I missing something horribly?


-Gaurav
http://www.edujini.in</description>
		<content:encoded><![CDATA[<p>Why do we need it when a simple ternary operator already exists&#8230;</p>
<p>Also, would like to know which of the &#8220;most languages&#8221; have the iif function?</p>
<p>PHP: No<br />
C: No<br />
C++: No<br />
PERL: No<br />
Python: No<br />
Java: No<br />
C#: No<br />
Visual Basic .Net: No<br />
J#: No</p>
<p>Or am I missing something horribly?</p>
<p>-Gaurav<br />
<a href='http://www.edujini.in' rel='nofollow'>http://www.edujini.in</a>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Mike</title>
		<link>http://www.phpit.net/code/iif-function/#comment-1291</link>
		<pubDate>Fri, 21 Apr 2006 09:25:39 +0000</pubDate>
		<guid>http://www.phpit.net/code/iif-function/#comment-1291</guid>
					<description>Can this be adapted to produce multiple options? i.e. in Access I sometimes use something like

output = IIF(a="1", "I am a", IIF(a="2", "I am b", "I am c"))</description>
		<content:encoded><![CDATA[<p>Can this be adapted to produce multiple options? i.e. in Access I sometimes use something like</p>
<p>output = IIF(a=&#8221;1&#8243;, &#8220;I am a&#8221;, IIF(a=&#8221;2&#8243;, &#8220;I am b&#8221;, &#8220;I am c&#8221;))
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Ezine Articles &#187; Track your visitors, using PHP</title>
		<link>http://www.phpit.net/code/iif-function/#comment-220</link>
		<pubDate>Sat, 26 Nov 2005 08:47:49 +0000</pubDate>
		<guid>http://www.phpit.net/code/iif-function/#comment-220</guid>
					<description>[...] Note: I used a function in the above example called iif(). You can get this function at http://www.phpit.net/code/iif-function. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Note: I used a function in the above example called iif(). You can get this function at <a href='http://www.phpit.net/code/iif-function.' rel='nofollow'>http://www.phpit.net/code/iif-function.</a> [&#8230;]
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
