<?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/"
		>
<channel>
	<title>Comments on: Top 5 Most Useful non-native PHP functions</title>
	<atom:link href="http://www.razzed.com/2009/01/14/top-5-most-useful-non-native-php-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.razzed.com/2009/01/14/top-5-most-useful-non-native-php-functions/</link>
	<description>Blunt Musings: Analytics, Search, Marketing, and Privacy. And other random thoughts.</description>
	<lastBuildDate>Tue, 13 Dec 2011 01:23:13 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: kent</title>
		<link>http://www.razzed.com/2009/01/14/top-5-most-useful-non-native-php-functions/comment-page-1/#comment-248</link>
		<dc:creator>kent</dc:creator>
		<pubDate>Thu, 16 Dec 2010 16:18:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.razzed.com/?p=8#comment-248</guid>
		<description>Absolutely good tip, but you don&#039;t want the &quot;isset&quot; result, you want the value from $_GET[&#039;name&#039;].

So, I think what you want is:

$name = @$_GET[&#039;name&#039;] :? &#039;default&#039;;

isset returns a boolean, so your latter 

&lt;code&gt;isset($arr[$name]) ?: &#039;default&#039;&lt;/code&gt;

returns true or &#039;default&#039;.

I&#039;m going to say that I prefer the syntactic sugar of using avalue. While I use it a lot, it&#039;s not a huge CPU hog and it adds a nice hook for debugging. I put in assert statements to make sure that $name is not NULL and is a proper scalar. This finds a variety of errors.

Translating the above $language_path to your syntax becomes:
&lt;code&gt;
$language_path = @$languages[@$_GET[&#039;language&#039;] :? $def_lang] :? $languages[$def_lang];
&lt;/code&gt;

Which isn&#039;t too shabby, actually, though it may confuse some...

Thanks for the comments!</description>
		<content:encoded><![CDATA[<p>Absolutely good tip, but you don&#8217;t want the &#8220;isset&#8221; result, you want the value from $_GET['name'].</p>
<p>So, I think what you want is:</p>
<p>$name = @$_GET['name'] :? &#8216;default&#8217;;</p>
<p>isset returns a boolean, so your latter </p>
<p><code>isset($arr[$name]) ?: 'default'</code></p>
<p>returns true or &#8216;default&#8217;.</p>
<p>I&#8217;m going to say that I prefer the syntactic sugar of using avalue. While I use it a lot, it&#8217;s not a huge CPU hog and it adds a nice hook for debugging. I put in assert statements to make sure that $name is not NULL and is a proper scalar. This finds a variety of errors.</p>
<p>Translating the above $language_path to your syntax becomes:<br />
<code><br />
$language_path = @$languages[@$_GET['language'] :? $def_lang] :? $languages[$def_lang];<br />
</code></p>
<p>Which isn&#8217;t too shabby, actually, though it may confuse some&#8230;</p>
<p>Thanks for the comments!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.razzed.com/2009/01/14/top-5-most-useful-non-native-php-functions/comment-page-1/#comment-245</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Mon, 13 Dec 2010 11:05:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.razzed.com/?p=8#comment-245</guid>
		<description>How about replacing avalue() with:

$name = isset($_GET[&#039;name&#039;]) ? $_GET[&#039;name&#039;] : &#039;default&#039;;

or

$name = @$_GET[&#039;name&#039;] ? $_GET[&#039;name&#039;] : &#039;default&#039;;

or (php 5.3) shorter

$name = @$_GET[&#039;name&#039;] ?: &#039;default&#039;;

or better still (php 5.3) longer

$name = isset($_GET[&#039;name&#039;]) ?: &#039;default&#039;;

personally if you&#039;re running php 5.3+ then i would use 
$name = isset($_GET[&#039;name&#039;]) ?: &#039;default&#039;;
instead of avalue() ;-)

Kind regards,
Scott</description>
		<content:encoded><![CDATA[<p>How about replacing avalue() with:</p>
<p>$name = isset($_GET['name']) ? $_GET['name'] : &#8216;default&#8217;;</p>
<p>or</p>
<p>$name = @$_GET['name'] ? $_GET['name'] : &#8216;default&#8217;;</p>
<p>or (php 5.3) shorter</p>
<p>$name = @$_GET['name'] ?: &#8216;default&#8217;;</p>
<p>or better still (php 5.3) longer</p>
<p>$name = isset($_GET['name']) ?: &#8216;default&#8217;;</p>
<p>personally if you&#8217;re running php 5.3+ then i would use<br />
$name = isset($_GET['name']) ?: &#8216;default&#8217;;<br />
instead of avalue() ;-)</p>
<p>Kind regards,<br />
Scott</p>
]]></content:encoded>
	</item>
</channel>
</rss>

