<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: PHP Shorthand If/Else Using Ternary Operators&#160;(?:)</title> <atom:link href="http://davidwalsh.name/php-shorthand-if-else-ternary-operators/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 19:56:08 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: kirk bushell</title><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators#comment-32073</link> <dc:creator>kirk bushell</dc:creator> <pubDate>Tue, 08 May 2012 04:53:14 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-shorthand-ifelse-using-ternary-operators/#comment-32073</guid> <description>Good article, I&#039;m glad some poeple cover this. One thing should be mentioned though - this should definitely not be used heavily. Embedded ternary operators, and nested ternary operators are a developer&#039;s worst nightmare - it creates unnecessarily unreadable code that is difficult to maintain. Sometimes more code is better! :)</description> <content:encoded><![CDATA[<p>Good article, I&#8217;m glad some poeple cover this. One thing should be mentioned though &#8211; this should definitely not be used heavily. Embedded ternary operators, and nested ternary operators are a developer&#8217;s worst nightmare &#8211; it creates unnecessarily unreadable code that is difficult to maintain. Sometimes more code is better! :)</p> ]]></content:encoded> </item> <item><title>By: Kocio</title><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators#comment-31476</link> <dc:creator>Kocio</dc:creator> <pubDate>Sun, 08 Apr 2012 10:09:41 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-shorthand-ifelse-using-ternary-operators/#comment-31476</guid> <description>Excellent... would be. But parts of the page does not display under Opera/NetBSD. Please fix it. TIA</description> <content:encoded><![CDATA[<p>Excellent&#8230; would be. But parts of the page does not display under Opera/NetBSD. Please fix it. TIA</p> ]]></content:encoded> </item> <item><title>By: Eight</title><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators#comment-29069</link> <dc:creator>Eight</dc:creator> <pubDate>Mon, 06 Feb 2012 21:53:15 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-shorthand-ifelse-using-ternary-operators/#comment-29069</guid> <description>Great article.
In the first example, I think it&#039;s the same thing as doing :
$var_is_greater_than_two = ($var &gt; 2);
Right ?</description> <content:encoded><![CDATA[<p>Great article.<br
/> In the first example, I think it&#8217;s the same thing as doing :<br
/> $var_is_greater_than_two = ($var &gt; 2);<br
/> Right ?</p> ]]></content:encoded> </item> <item><title>By: David</title><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators#comment-26370</link> <dc:creator>David</dc:creator> <pubDate>Fri, 05 Aug 2011 18:05:47 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-shorthand-ifelse-using-ternary-operators/#comment-26370</guid> <description>Hey Dave!
I don&#039;t use ternary very often, but is really nice in spots where things need to be tidy.I have a bit of a word of advice here on the use of ternary and collaboration. Dave addresses that in his points above, &quot;Tips for Using Ternary Operators&quot;.As a rule I use ternary only if the If/Else is a &#039;single line of code&#039; &lt;--- Yes this is variable depending on screen size. Just don&#039;t go overboard when working collaboratively or if there is a chance some-one else will inherit the code.</description> <content:encoded><![CDATA[<p>Hey Dave!<br
/> I don&#8217;t use ternary very often, but is really nice in spots where things need to be tidy.</p><p>I have a bit of a word of advice here on the use of ternary and collaboration. Dave addresses that in his points above, &#8220;Tips for Using Ternary Operators&#8221;.</p><p>As a rule I use ternary only if the If/Else is a &#8216;single line of code&#8217; &lt;&#8212; Yes this is variable depending on screen size. Just don&#039;t go overboard when working collaboratively or if there is a chance some-one else will inherit the code.</p> ]]></content:encoded> </item> <item><title>By: GTershel</title><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators#comment-26336</link> <dc:creator>GTershel</dc:creator> <pubDate>Thu, 04 Aug 2011 04:07:20 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-shorthand-ifelse-using-ternary-operators/#comment-26336</guid> <description>QuestionWhat is wrong with this code, I keep receiving an error.
Creating a sticky form and I am using a simple if (submit) then ($_POST[&#039;value&#039;])
&lt;code&gt;Please enter your short description of the category (blurb):
&lt;textarea id=&quot;catblurb&quot; name=&quot;catBlurb&quot;  value=&quot;
&quot;&gt;
Please enter a small description about this category.
&lt;/code&gt;
I only need the if part of the if/else.Thanks for any help</description> <content:encoded><![CDATA[<p>Question</p><p>What is wrong with this code, I keep receiving an error.<br
/> Creating a sticky form and I am using a simple if (submit) then ($_POST['value'])<br
/> <code></p><p>Please enter your short description of the category (blurb):<br
/> &lt;textarea id=&quot;catblurb&quot; name=&quot;catBlurb&quot;  value=&quot;<br
/> "&gt;<br
/> Please enter a small description about this category.</p><p></code><br
/> I only need the if part of the if/else.</p><p>Thanks for any help</p> ]]></content:encoded> </item> <item><title>By: MSinclair</title><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators#comment-25855</link> <dc:creator>MSinclair</dc:creator> <pubDate>Sat, 09 Jul 2011 14:47:33 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-shorthand-ifelse-using-ternary-operators/#comment-25855</guid> <description>The comma is not a typo. Echo can take multiple strings as arguments. :)http://php.net/manual/en/function.echo.php</description> <content:encoded><![CDATA[<p>The comma is not a typo. Echo can take multiple strings as arguments. :)</p><p><a
href="http://php.net/manual/en/function.echo.php" rel="nofollow">http://php.net/manual/en/function.echo.php</a></p> ]]></content:encoded> </item> <item><title>By: Stjepano</title><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators#comment-24524</link> <dc:creator>Stjepano</dc:creator> <pubDate>Tue, 28 Jun 2011 18:39:15 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-shorthand-ifelse-using-ternary-operators/#comment-24524</guid> <description>These are nice shorthands, but be warned, it will make your code unreadable and less understandable.</description> <content:encoded><![CDATA[<p>These are nice shorthands, but be warned, it will make your code unreadable and less understandable.</p> ]]></content:encoded> </item> <item><title>By: Danny</title><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators#comment-23469</link> <dc:creator>Danny</dc:creator> <pubDate>Tue, 12 Apr 2011 13:38:13 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-shorthand-ifelse-using-ternary-operators/#comment-23469</guid> <description>/* echo, inline */
echo &#039;Based on your score, you are a &#039;,($score &gt; 10 ? &#039;genius&#039; : &#039;nobody&#039;); //harsh!I think you may a typo with the &#039;,&#039; instead of a &#039;.&#039;</description> <content:encoded><![CDATA[<p>/* echo, inline */<br
/> echo &#8216;Based on your score, you are a &#8216;,($score &gt; 10 ? &#8216;genius&#8217; : &#8216;nobody&#8217;); //harsh!</p><p>I think you may a typo with the &#8216;,&#8217; instead of a &#8216;.&#8217;</p> ]]></content:encoded> </item> <item><title>By: Oussama</title><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators#comment-20879</link> <dc:creator>Oussama</dc:creator> <pubDate>Mon, 04 Oct 2010 18:15:44 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-shorthand-ifelse-using-ternary-operators/#comment-20879</guid> <description>&lt;code&gt;&lt;/code&gt;</description> <content:encoded><![CDATA[<p><code></p><p></code></p> ]]></content:encoded> </item> <item><title>By: A.Lepe</title><link>http://davidwalsh.name/php-shorthand-if-else-ternary-operators#comment-18400</link> <dc:creator>A.Lepe</dc:creator> <pubDate>Fri, 25 Jun 2010 01:10:06 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-shorthand-ifelse-using-ternary-operators/#comment-18400</guid> <description>@Richard:If you have some experience with Javascript I would say that it is similar to:var test = result &#124;&#124; error;  //Javascript
$test = $result ?: $error;  //PHPIn which it would return &quot;result&quot; value if it is not empty [1]. Otherwise it will return &quot;error&quot; value.I hope I was clear.[1] : For empty values see: http://www.php.net/manual/en/function.empty.php</description> <content:encoded><![CDATA[<p>@Richard:</p><p>If you have some experience with Javascript I would say that it is similar to:</p><p>var test = result || error;  //Javascript<br
/> $test = $result ?: $error;  //PHP</p><p>In which it would return &#8220;result&#8221; value if it is not empty [1]. Otherwise it will return &#8220;error&#8221; value.</p><p>I hope I was clear.</p><p>[1] : For empty values see: <a
href="http://www.php.net/manual/en/function.empty.php" rel="nofollow">http://www.php.net/manual/en/function.empty.php</a></p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 1/7 queries in 0.007 seconds using disk: basic
Object Caching 804/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 16:48:28 -->
