<?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: Use is_null rather than == null</title>
	<atom:link href="http://mostafa.mosmar.com/blog/2009/09/21/use-is_null-rather-than-null/feed/" rel="self" type="application/rss+xml" />
	<link>http://mostafa.mosmar.com/blog/2009/09/21/use-is_null-rather-than-null/</link>
	<description></description>
	<lastBuildDate>Sat, 03 Jul 2010 04:45:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: مصطفى</title>
		<link>http://mostafa.mosmar.com/blog/2009/09/21/use-is_null-rather-than-null/comment-page-1/#comment-246</link>
		<dc:creator>مصطفى</dc:creator>
		<pubDate>Mon, 21 Sep 2009 11:53:23 +0000</pubDate>
		<guid isPermaLink="false">http://mostafa.mosmar.com/blog/?p=126#comment-246</guid>
		<description><div style="text-align:left;direction:ltr">Strictly speaking
$foo = &#039;&#039; is an empty (String)
$foo = null is nothing , not a number not a object , just nothing

In most ,if not all, programming languages null is not equal to an empty string or integer who&#039;s value is zero.

PHP on the other appears to allow this

consider this example

function getPhoneNumberFromDatabase(){
  
if( $db-&gt;getConnection()  == false ){
  return null;  
}

return $db-&gt;getPhoneNumber();
}

in many cases you will want your functions to return NULL upon failure

so if we do this

$phone = getPhoneNumberFromDatabase();
if( $phone == null ){
  echo &#039;Database connection failed&#039;;
}

In this case , PHP will report that &quot;Database connection failed&quot; even if the connection is okay but the phone number was an empty string.

That&#039;s why you should use is_null or === null</div></description>
		<content:encoded><![CDATA[<div class="english-text" ><p>Strictly speaking<br />
$foo = &#8221; is an empty (String)<br />
$foo = null is nothing , not a number not a object , just nothing</p>
<p>In most ,if not all, programming languages null is not equal to an empty string or integer who&#8217;s value is zero.</p>
<p>PHP on the other appears to allow this</p>
<p>consider this example</p>
<p>function getPhoneNumberFromDatabase(){</p>
<p>if( $db-&gt;getConnection()  == false ){<br />
  return null;<br />
}</p>
<p>return $db-&gt;getPhoneNumber();<br />
}</p>
<p>in many cases you will want your functions to return NULL upon failure</p>
<p>so if we do this</p>
<p>$phone = getPhoneNumberFromDatabase();<br />
if( $phone == null ){<br />
  echo &#8216;Database connection failed&#8217;;<br />
}</p>
<p>In this case , PHP will report that &#8220;Database connection failed&#8221; even if the connection is okay but the phone number was an empty string.</p>
<p>That&#8217;s why you should use is_null or === null</p>
</div>]]></content:encoded>
	</item>
	<item>
		<title>By: Ahmad Alfy</title>
		<link>http://mostafa.mosmar.com/blog/2009/09/21/use-is_null-rather-than-null/comment-page-1/#comment-245</link>
		<dc:creator>Ahmad Alfy</dc:creator>
		<pubDate>Mon, 21 Sep 2009 10:40:54 +0000</pubDate>
		<guid isPermaLink="false">http://mostafa.mosmar.com/blog/?p=126#comment-245</guid>
		<description><div style="text-align:left;direction:ltr">so, $foo = &#039;&#039; doesn&#039;t make $foo null!
right?</div></description>
		<content:encoded><![CDATA[<div class="english-text" ><p>so, $foo = &#8221; doesn&#8217;t make $foo null!<br />
right?</p>
</div>]]></content:encoded>
	</item>
</channel>
</rss>
