<?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://organizeseries.com/"
		>
<channel>
	<title>Comments on: Really, Always Return Something</title>
	<atom:link href="http://www.brandonsavage.net/really-always-return-something/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonsavage.net/really-always-return-something/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=really-always-return-something</link>
	<description>The personal blog of Brandon Savage. Contains entries of a personal and professional nature focusing on PHP, Apple, LAMP, MySQL and Washington, DC.</description>
	<lastBuildDate>Wed, 15 May 2013 14:54:51 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.2-alpha</generator>
	<item>
		<title>By: Timothy de Paris</title>
		<link>http://www.brandonsavage.net/really-always-return-something/#comment-10236</link>
		<dc:creator>Timothy de Paris</dc:creator>
		<pubDate>Thu, 21 Mar 2013 09:11:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=2304#comment-10236</guid>
		<description><![CDATA[I&#039;m glad you corrected your previous post, and now agree with the case you are making.

Despite PHP not being a strongly-typed language, I am a great proponent of keeping code as strongly typed as possible. Therefore, rather than returning multiple types like many core PHP functions (for example strpos, which returns an integer or FALSE if the substring could not be found), we should return NULL to indicate that no appropriate return value was available.

I also strongly agree that NULL should never be used in error cases. Throwing an exception (or a range of different exceptions depending on the error state) allows the function caller to handle any error cases as required, ensuring the application remains in a stable state.

Unfortunately in PHP returning nothing and returning NULL are exactly the same, as opposed to languages such as JavaScript where NULL (the intentional absence of a value)and UNDEFINED (the unintentional absence of a value) are distinct types, however, as you say, it is still good practice to include a return statement in a function even if it doesn&#039;t return anything.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m glad you corrected your previous post, and now agree with the case you are making.</p>
<p>Despite PHP not being a strongly-typed language, I am a great proponent of keeping code as strongly typed as possible. Therefore, rather than returning multiple types like many core PHP functions (for example strpos, which returns an integer or FALSE if the substring could not be found), we should return NULL to indicate that no appropriate return value was available.</p>
<p>I also strongly agree that NULL should never be used in error cases. Throwing an exception (or a range of different exceptions depending on the error state) allows the function caller to handle any error cases as required, ensuring the application remains in a stable state.</p>
<p>Unfortunately in PHP returning nothing and returning NULL are exactly the same, as opposed to languages such as JavaScript where NULL (the intentional absence of a value)and UNDEFINED (the unintentional absence of a value) are distinct types, however, as you say, it is still good practice to include a return statement in a function even if it doesn&#8217;t return anything.</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 (Feed is rejected)
Page Caching using disk: enhanced (User agent is rejected)
Object Caching 488/506 objects using apc
Content Delivery Network via Amazon Web Services: S3: brandonsavage-net-files.s3.amazonaws.com

 Served from: www.brandonsavage.net @ 2013-05-24 09:43:34 by W3 Total Cache -->