<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ehsanul Haque &#187; def</title>
	<atom:link href="http://ehsan.bdwebwork.com/tag/def/feed/" rel="self" type="application/rss+xml" />
	<link>http://ehsan.bdwebwork.com</link>
	<description>Welcome to my personal site &#38; blog</description>
	<lastBuildDate>Wed, 07 Jul 2010 13:14:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PHP Function I frquently use</title>
		<link>http://ehsan.bdwebwork.com/2007/10/05/php-function-i-frquently-use/</link>
		<comments>http://ehsan.bdwebwork.com/2007/10/05/php-function-i-frquently-use/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 23:06:43 +0000</pubDate>
		<dc:creator>Ehsan</dc:creator>
				<category><![CDATA[Codes]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[def]]></category>
		<category><![CDATA[default]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[lastLoginDate]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[lot]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[purpose]]></category>
		<category><![CDATA[result]]></category>
		<category><![CDATA[value]]></category>
		<category><![CDATA[var]]></category>
		<category><![CDATA[variable]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://ehsan.bdwebwork.com/?p=64</guid>
		<description><![CDATA[While developing the web applications with PHP I have made my own small function library. In this library I have few functions that I use very frequently. One of the functions that is used more often is echo_d(). The purpose &#8230; <a href="http://ehsan.bdwebwork.com/2007/10/05/php-function-i-frquently-use/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While developing the web applications with PHP I have made my own small function library. In this library I have few functions that I use very frequently. One of the functions that is used more often is <span style="font-family: Courier; color: #008100;">echo_d()</span>. The purpose of this function is to check a variable to see if it is empty or not set; then based on the check result it either prints a default value or the value of the variable.</p>
<p>This is a simple function that saves me a lot of time and keeps my main codes cleaner. So here it is.</p>
<pre name="code" class="php">
function echo_d($var, $def) {
  $var = trim($var);
  echo ((isset($var)) &amp;&amp; (!empty($var))) ? $var : $def;
}
</pre>
<p>When to use this function? One of the most common places I use this function is in the reports. When I am generating reports for anything I always have to check whether certain value is in the database; it prints a default value if it cannot find one. The usage of this function in the scenario is something like:</p>
<pre name="code" class="php">$lastLoginDate = $rowsFromDB['last_login_date'];
echo_d($lastLoginDate, "---");</pre>
<p>This function can be expanded to make it more versatile but I have found this tiny little function very useful.</p>
<p><span style="font-weight: bold;">&#8211;</span><br style="font-weight: bold;" /><span style="font-weight: bold;">Thank you.</span><br style="font-weight: bold;" /></p>
]]></content:encoded>
			<wfw:commentRss>http://ehsan.bdwebwork.com/2007/10/05/php-function-i-frquently-use/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
