<?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>MyGeekPal &#187; PHP</title>
	<atom:link href="http://www.mygeekpal.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mygeekpal.com</link>
	<description>Techy tips and recipes  from your geek pal</description>
	<lastBuildDate>Tue, 06 Jul 2010 12:09:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to convert Exponentials to Decimals in PHP</title>
		<link>http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/</link>
		<comments>http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 16:00:35 +0000</pubDate>
		<dc:creator>Atif</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[decimal]]></category>
		<category><![CDATA[exponent]]></category>
		<category><![CDATA[trick]]></category>

		<guid isPermaLink="false">http://www.mygeekpal.com/?p=650</guid>
		<description><![CDATA[A while ago I was experimenting on how long does it take for a plain page to load on my local server. The output I was receiving was so small that it was being displayed in exponential form rather than decimal something like this 2.8848648071289E-5. Well, to be honest I hate numbers with exponents because [...]]]></description>
			<content:encoded><![CDATA[<pre class="php" name="code"><img class="alignright" src="http://www.mygeekpal.com/wp-content/uploads/2009/11/php-string.jpg" alt="" width="268" height="201" /></pre>
<p>A while ago I was experimenting on how long does it take for a plain page to load on my local server. The output I was receiving was so small that it was being displayed in exponential form rather than decimal something like this 2.8848648071289E-5.<br />
Well, to be honest I hate numbers with exponents because they are so confusing and secondly because they look ugly.</p>
<p>A quick Google for converting exponents to decimal didn&#8217;t work out for me, so I started out writing my own function using regular expressions except for the information that PHP automatically converts numbers with high precision into exponential form. <strong>&#8220;Strings!&#8221;</strong> was the first thing that flicked my mind reading that ad the second was <strong>&#8220;Regular Expressions&#8221;</strong></p>
<p>So I made my own function to convert exponential into decimal, and the good thing is.. it works. Here is the trick</p>
<pre class="php" name="code">$total_time = 2.8848648071289E-5;

echo exp2dec($total_time);

function exp2dec($number) {
	preg_match('/(.*)E-(.*)/', str_replace(".", "", $number), $matches);
	$num = "0.";
	while ($matches[2] &gt; 0) {
		$num .= "0";
		$matches[2]--;
	}
	return $num . $matches[1];
}
</pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-spaced shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/&amp;title=How+to+convert+Exponentials+to+Decimals+in+PHP" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-designfloat">
			<a href="http://www.designfloat.com/submit.php?url=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/&amp;title=How+to+convert+Exponentials+to+Decimals+in+PHP" rel="nofollow" title="Submit this to DesignFloat">Submit this to DesignFloat</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/&amp;t=How+to+convert+Exponentials+to+Decimals+in+PHP" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=How+to+convert+Exponentials+to+Decimals+in+PHP&amp;link=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/&amp;title=How+to+convert+Exponentials+to+Decimals+in+PHP&amp;summary=%0D%0AA%20while%20ago%20I%20was%20experimenting%20on%20how%20long%20does%20it%20take%20for%20a%20plain%20page%20to%20load%20on%20my%20local%20server.%20The%20output%20I%20was%20receiving%20was%20so%20small%20that%20it%20was%20being%20displayed%20in%20exponential%20form%20rather%20than%20decimal%20something%20like%20this%202.8848648071289E-5.%0D%0AWell%2C%20to%20be%20honest%20I%20hate%20numbers%20with%20exponent&amp;source=MyGeekPal" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/&amp;title=How+to+convert+Exponentials+to+Decimals+in+PHP" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/&amp;h=How+to+convert+Exponentials+to+Decimals+in+PHP" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=How+to+convert+Exponentials+to+Decimals+in+PHP&amp;du=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/&amp;cn=%0D%0AA%20while%20ago%20I%20was%20experimenting%20on%20how%20long%20does%20it%20take%20for%20a%20plain%20page%20to%20load%20on%20my%20local%20server.%20The%20output%20I%20was%20receiving%20was%20so%20small%20that%20it%20was%20being%20displayed%20in%20exponential%20form%20rather%20than%20decimal%20something%20like%20this%202.8848648071289E-5.%0D%0AWell%2C%20to%20be%20honest%20I%20hate%20numbers%20with%20exponent" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/&amp;title=How+to+convert+Exponentials+to+Decimals+in+PHP" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=How+to+convert+Exponentials+to+Decimals+in+PHP+-+&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/&amp;submitHeadline=How+to+convert+Exponentials+to+Decimals+in+PHP&amp;submitSummary=%0D%0AA%20while%20ago%20I%20was%20experimenting%20on%20how%20long%20does%20it%20take%20for%20a%20plain%20page%20to%20load%20on%20my%20local%20server.%20The%20output%20I%20was%20receiving%20was%20so%20small%20that%20it%20was%20being%20displayed%20in%20exponential%20form%20rather%20than%20decimal%20something%20like%20this%202.8848648071289E-5.%0D%0AWell%2C%20to%20be%20honest%20I%20hate%20numbers%20with%20exponent&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<img src="http://www.mygeekpal.com/?ak_action=api_record_view&id=650&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.mygeekpal.com/650/how-to-convert-exponentials-to-decimals-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to display your twitter follower count using PHP</title>
		<link>http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/</link>
		<comments>http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 14:05:57 +0000</pubDate>
		<dc:creator>Atif</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[followers]]></category>

		<guid isPermaLink="false">http://www.mygeekpal.com/?p=326</guid>
		<description><![CDATA[Got over 1000 followers on twitter? And you want to flaunt your twitter follower count proudly on your blog. The following PHP code is aÂ  PHP cURL code implementation to pull out the twitter followers using REST API. It will get you the number of followers on twitter using the cURL library. Just change the [...]]]></description>
			<content:encoded><![CDATA[<p>Got over 1000 followers on twitter? And you want to flaunt your twitter follower count proudly on your blog. The following PHP code is aÂ  PHP cURL code implementation to pull out the twitter followers using REST API. It will get you the number of followers on twitter using the cURL library. Just change the $screen_name and the script is pretty self explanatory. The code is tested working, You are free to do anything with this code, I take no responsibility further however you can ask me for support. I will try to help you out if I can.</p>
<p><span style="color: #ff0000;"><code><strong>NOTE: The code won't work for an hour if you 100 API calls per hours are completed.</strong></code></span></p>
<pre class="php" name="code">&lt;?
// get the number of followers

$screen_name = "atif089";Â Â Â Â Â Â  // dont forget to chagne your username
$html = process("http://twitter.com/users/show.xml?screen_name=$screen_name");

// Parse the number of followers
$pattern = '&lt;followers_count&gt;(.*)&lt;\/followers_count&gt;';
ereg($pattern, $html, $matches);

// change this HTML as per your requirement
echo "&lt;a href=\"http://twitter.com/$screen_name\"&gt;Follow me on twitter: (".$matches[1]." followers)&lt;/a&gt;";

/**
 * process : This method open a URL via cURL library
 *
 * @param string $url (must) This is the URL that you would like to open
 * @param string $postargs (optional) Any arguments that you would like to send via POST method
 *
 */

 function process($url,$postargs=false){
 $ch = curl_init($url);
 if($postargs !== false){
 curl_setopt ($ch, CURLOPT_POST, true);
 curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs);
 }
 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11");
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 $response = curl_exec($ch);
 curl_close($ch);
 return $response;
 }
?&gt;</pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-spaced shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/&amp;title=How+to+display+your+twitter+follower+count+using+PHP" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-designfloat">
			<a href="http://www.designfloat.com/submit.php?url=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/&amp;title=How+to+display+your+twitter+follower+count+using+PHP" rel="nofollow" title="Submit this to DesignFloat">Submit this to DesignFloat</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/&amp;t=How+to+display+your+twitter+follower+count+using+PHP" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=How+to+display+your+twitter+follower+count+using+PHP&amp;link=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/&amp;title=How+to+display+your+twitter+follower+count+using+PHP&amp;summary=Got%20over%201000%20followers%20on%20twitter%3F%20And%20you%20want%20to%20flaunt%20your%20twitter%20follower%20count%20proudly%20on%20your%20blog.%20The%20following%20PHP%20code%20is%20a%C3%82%C2%A0%20PHP%20cURL%20code%20implementation%20to%20pull%20out%20the%20twitter%20followers%20using%20REST%20API.%20It%20will%20get%20you%20the%20number%20of%20followers%20on%20twitter%20using%20the%20cURL%20library.%20Just%20&amp;source=MyGeekPal" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/&amp;title=How+to+display+your+twitter+follower+count+using+PHP" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/&amp;h=How+to+display+your+twitter+follower+count+using+PHP" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=How+to+display+your+twitter+follower+count+using+PHP&amp;du=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/&amp;cn=Got%20over%201000%20followers%20on%20twitter%3F%20And%20you%20want%20to%20flaunt%20your%20twitter%20follower%20count%20proudly%20on%20your%20blog.%20The%20following%20PHP%20code%20is%20a%C3%82%C2%A0%20PHP%20cURL%20code%20implementation%20to%20pull%20out%20the%20twitter%20followers%20using%20REST%20API.%20It%20will%20get%20you%20the%20number%20of%20followers%20on%20twitter%20using%20the%20cURL%20library.%20Just%20" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/&amp;title=How+to+display+your+twitter+follower+count+using+PHP" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=How+to+display+your+twitter+follower+count+using+PHP+-+&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/&amp;submitHeadline=How+to+display+your+twitter+follower+count+using+PHP&amp;submitSummary=Got%20over%201000%20followers%20on%20twitter%3F%20And%20you%20want%20to%20flaunt%20your%20twitter%20follower%20count%20proudly%20on%20your%20blog.%20The%20following%20PHP%20code%20is%20a%C3%82%C2%A0%20PHP%20cURL%20code%20implementation%20to%20pull%20out%20the%20twitter%20followers%20using%20REST%20API.%20It%20will%20get%20you%20the%20number%20of%20followers%20on%20twitter%20using%20the%20cURL%20library.%20Just%20&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<img src="http://www.mygeekpal.com/?ak_action=api_record_view&id=326&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.mygeekpal.com/326/how-to-display-your-twitter-follower-count-using-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Including Files in PHP &#8211; Learn PHP in 7 Days &#8211; Day #6</title>
		<link>http://www.mygeekpal.com/266/including-files-in-php/</link>
		<comments>http://www.mygeekpal.com/266/including-files-in-php/#comments</comments>
		<pubDate>Sat, 30 May 2009 12:39:44 +0000</pubDate>
		<dc:creator>Atif</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[include]]></category>
		<category><![CDATA[require]]></category>

		<guid isPermaLink="false">http://www.mygeekpal.com/?p=266</guid>
		<description><![CDATA[Include Function Including files bring more convenience in managing your code. As the name states, include is a function that will simply dump the contents of the included file into the current file. This is cool because some times you may need some code that should be available on all pages. Say a menu or [...]]]></description>
			<content:encoded><![CDATA[<h3>Include Function</h3>
<p>Including files bring more convenience in managing your  code. As the name states, include is a function that will simply dump the  contents of the included file into the current file. This is cool because some  times you may need some code that should be available on all pages. Say a menu or  a website header.</p>
<p>Including files saves a lot of efforts by writing your code  multiple times on each page. Yeah I know you copy and paste but that requires  some more efforts too comparatively. Suppose you suddenly add a page in menu.  Then? You need to update all the files. Using include function we can just  create one file and include it all over in other files. Hence editing only one  file will modify code in your other files.</p>
<p>I hope I am clear enough in explaining this to you. Let us  start with an example. Oh before that, the syntax for include function is</p>
<pre class="php" name="code">&lt;?php include("filename.php"); ?&gt;</pre>
<p>So let us first create a file called menu.php The file  content would be something like this.</p>
<pre class="php" name="code">&lt;a href="#"&gt;Home&lt;/a&gt; -
&lt;a href="#"&gt;About Us&lt;/a&gt; -
&lt;a href="#"&gt;Contact Us&lt;/a&gt; &lt;br /&gt;</pre>
<p>Now let us create an index.php file. The index.php file will  contain some content as well as the menu file. So this is what the code will be  in index.php file</p>
<pre class="php" name="code">&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Testing Include File&lt;/title&gt;
&lt;head/&gt;
&lt;body&gt;
&lt;?php include("menu.php"); ?&gt;
&lt;p&gt;This page is created to display the working of include  function&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>See the preview</p>
<p><img class="alignnone size-full wp-image-267" title="7-include" src="http://www.mygeekpal.com/wp-content/uploads/2009/05/7-include.jpg" alt="7-include" width="402" height="149" /></p>
<h3>Require Function</h3>
<p>The require function is almost same as the include function.  The only difference is in error handling. When the included file doesn&#8217;t exist,  a warning is displayed and the execution is preceded.</p>
<p>Where as when a file included via require function does not  exist, then a fatal error is displayed and the execution is halted at the same  line. The syntax is</p>
<p>&lt;?php require(&#8220;filename.php&#8221;); ?&gt;</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-spaced shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.mygeekpal.com/266/including-files-in-php/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mygeekpal.com/266/including-files-in-php/&amp;title=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-designfloat">
			<a href="http://www.designfloat.com/submit.php?url=http://www.mygeekpal.com/266/including-files-in-php/&amp;title=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236" rel="nofollow" title="Submit this to DesignFloat">Submit this to DesignFloat</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mygeekpal.com/266/including-files-in-php/&amp;t=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236&amp;link=http://www.mygeekpal.com/266/including-files-in-php/" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.mygeekpal.com/266/including-files-in-php/&amp;title=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236&amp;summary=Include%20Function%0D%0AIncluding%20files%20bring%20more%20convenience%20in%20managing%20your%20%20code.%20As%20the%20name%20states%2C%20include%20is%20a%20function%20that%20will%20simply%20dump%20the%20%20contents%20of%20the%20included%20file%20into%20the%20current%20file.%20This%20is%20cool%20because%20some%20%20times%20you%20may%20need%20some%20code%20that%20should%20be%20available%20on%20all%20pages.%20Sa&amp;source=MyGeekPal" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.mygeekpal.com/266/including-files-in-php/&amp;title=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.mygeekpal.com/266/including-files-in-php/&amp;h=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236&amp;du=http://www.mygeekpal.com/266/including-files-in-php/&amp;cn=Include%20Function%0D%0AIncluding%20files%20bring%20more%20convenience%20in%20managing%20your%20%20code.%20As%20the%20name%20states%2C%20include%20is%20a%20function%20that%20will%20simply%20dump%20the%20%20contents%20of%20the%20included%20file%20into%20the%20current%20file.%20This%20is%20cool%20because%20some%20%20times%20you%20may%20need%20some%20code%20that%20should%20be%20available%20on%20all%20pages.%20Sa" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.mygeekpal.com/266/including-files-in-php/&amp;title=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mygeekpal.com/266/including-files-in-php/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236+-+&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mygeekpal.com/266/including-files-in-php/&amp;submitHeadline=Including+Files+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%236&amp;submitSummary=Include%20Function%0D%0AIncluding%20files%20bring%20more%20convenience%20in%20managing%20your%20%20code.%20As%20the%20name%20states%2C%20include%20is%20a%20function%20that%20will%20simply%20dump%20the%20%20contents%20of%20the%20included%20file%20into%20the%20current%20file.%20This%20is%20cool%20because%20some%20%20times%20you%20may%20need%20some%20code%20that%20should%20be%20available%20on%20all%20pages.%20Sa&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<img src="http://www.mygeekpal.com/?ak_action=api_record_view&id=266&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.mygeekpal.com/266/including-files-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Loops in PHP &#8211; Learn PHP in 7 Days &#8211; Day #5</title>
		<link>http://www.mygeekpal.com/259/using-loops-in-php/</link>
		<comments>http://www.mygeekpal.com/259/using-loops-in-php/#comments</comments>
		<pubDate>Sat, 30 May 2009 11:49:38 +0000</pubDate>
		<dc:creator>Atif</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[do]]></category>
		<category><![CDATA[loops]]></category>
		<category><![CDATA[while]]></category>

		<guid isPermaLink="false">http://www.mygeekpal.com/?p=259</guid>
		<description><![CDATA[Hope you are well versed with conditional statements in PHP. This time we are going to see how to work with looping structures. Looping structure are basically those statements which are to be executed recursively until some condition is fulfilled. PHP provides 3 types of looping structures While Loop Do While Loop For Loop While [...]]]></description>
			<content:encoded><![CDATA[<p>Hope you are well versed with conditional statements in PHP.  This time we are going to see how to work with looping structures. Looping  structure are basically those statements which are to be executed recursively  until some condition is fulfilled.</p>
<p>PHP provides 3 types of looping structures</p>
<ul type="disc">
<li>While Loop</li>
<li>Do While Loop</li>
<li>For Loop</li>
</ul>
<h3>While Loop</h3>
<p>While loops are the simplest form of looping structures in  PHP. If you have already worked with C then these resemble same as the while  loop in C. The basic syntax is</p>
<p><code>while (condition) {<br />
â€¦ Statement to be  executed<br />
â€¦ Statement to be  executed<br />
}</code></p>
<p>The above code will check for the condition and keeps  executing the statements inside the loop or block until the condition is  returned false. Let us see this with an example.</p>
<pre class="php" name="code">&lt;?php
// lets try to echo numbers 0 to 10
$a = 0;
while ($a &lt;= 10) {
echo $a;
$a++;
}
?&gt;</pre>
<p>The above code is pretty self explanatory, we took a  variable $a with value 0. The condition is to check if $a is equal or less then  10, Then print the value of a on the screen. Increment the value of a by 1.  Check the condition again and so on until the value of a is 10. and when it exceeds  10, the loop is terminated.</p>
<p><img class="alignnone size-full wp-image-261" title="6-while-loop-1" src="http://www.mygeekpal.com/wp-content/uploads/2009/05/6-while-loop-1.jpg" alt="6-while-loop-1" width="232" height="118" /></p>
<h3>Do While</h3>
<p>The Do While loop is almost similar to while loop. The only  thing it differs from a simple while loop is that here the statements are  executed first and then the condition is checked. The syntax is</p>
<p><code>do {<br />
â€¦ statement 1<br />
â€¦ statement 2<br />
}Â  while (condition) ;</code></p>
<p>Confused? Let us see an example</p>
<pre class="php" name="code">&lt;?php
$i = 0;
do {
echo ++$i;
} while ($i &lt; 10);
?&gt;</pre>
<p>Here we will see that the number from 1 to 10 are printed  even though our condition states that $i &lt; 10. This is because when the  value of $i is 9 the condition is true and since the statement gets printed  first, the value of $i is printed 10 and then the loop gets terminated as per  the condition. See the image and get an idea</p>
<p><img class="alignnone size-full wp-image-262" title="6-while-loop-2" src="http://www.mygeekpal.com/wp-content/uploads/2009/05/6-while-loop-2.jpg" alt="6-while-loop-2" width="251" height="107" /></p>
<h3>For Loop</h3>
<p>The for loop is the most complex loop in PHP. Behavior is  same like the for loop in C. Let see the syntax before explaining it.</p>
<p><code>for (expr1; expr2; expr3) {<br />
statement 1;<br />
statement 2;<br />
}</code></p>
<p>If you take a look, the expr1 is the expression that is  executed at the starting of the loop for once. Then the statements are  executed, and the condition is checked after each iteration. The condition is  stated in expr2. The another thing that is added here is the expr3. The expr3  is a statement that will be executed after each iteration. Looks like I&#8217;m  confusing you once again. Let&#8217;s see an example</p>
<pre class="php" name="code">&lt;?php
for ($i = 0; $i &lt; 10; $i++) {
echo $i;
}
?&gt;</pre>
<p>I hope the example makes you clear about the topic. Here  expr1 is executed first and $i is initialized. The next thing is the echo line  is executed. The iteration is over, now the condition is checked and if the  condition is true then expr3 i.e $i++ is executed and it goes into the loop  once again. The output</p>
<p><a href="http://www.mygeekpal.com/wp-content/uploads/2009/05/6-for-loop-1.jpg"><img class="alignnone size-full wp-image-263" title="6-for-loop-1" src="http://www.mygeekpal.com/wp-content/uploads/2009/05/6-for-loop-1.jpg" alt="6-for-loop-1" width="241" height="106" /></a></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-spaced shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.mygeekpal.com/259/using-loops-in-php/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mygeekpal.com/259/using-loops-in-php/&amp;title=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-designfloat">
			<a href="http://www.designfloat.com/submit.php?url=http://www.mygeekpal.com/259/using-loops-in-php/&amp;title=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235" rel="nofollow" title="Submit this to DesignFloat">Submit this to DesignFloat</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mygeekpal.com/259/using-loops-in-php/&amp;t=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235&amp;link=http://www.mygeekpal.com/259/using-loops-in-php/" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.mygeekpal.com/259/using-loops-in-php/&amp;title=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235&amp;summary=Hope%20you%20are%20well%20versed%20with%20conditional%20statements%20in%20PHP.%20%20This%20time%20we%20are%20going%20to%20see%20how%20to%20work%20with%20looping%20structures.%20Looping%20%20structure%20are%20basically%20those%20statements%20which%20are%20to%20be%20executed%20recursively%20%20until%20some%20condition%20is%20fulfilled.%0D%0A%0D%0APHP%20provides%203%20types%20of%20looping%20structures%0D%0A%0D&amp;source=MyGeekPal" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.mygeekpal.com/259/using-loops-in-php/&amp;title=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.mygeekpal.com/259/using-loops-in-php/&amp;h=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235&amp;du=http://www.mygeekpal.com/259/using-loops-in-php/&amp;cn=Hope%20you%20are%20well%20versed%20with%20conditional%20statements%20in%20PHP.%20%20This%20time%20we%20are%20going%20to%20see%20how%20to%20work%20with%20looping%20structures.%20Looping%20%20structure%20are%20basically%20those%20statements%20which%20are%20to%20be%20executed%20recursively%20%20until%20some%20condition%20is%20fulfilled.%0D%0A%0D%0APHP%20provides%203%20types%20of%20looping%20structures%0D%0A%0D" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.mygeekpal.com/259/using-loops-in-php/&amp;title=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mygeekpal.com/259/using-loops-in-php/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235+-+&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mygeekpal.com/259/using-loops-in-php/&amp;submitHeadline=Using+Loops+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%235&amp;submitSummary=Hope%20you%20are%20well%20versed%20with%20conditional%20statements%20in%20PHP.%20%20This%20time%20we%20are%20going%20to%20see%20how%20to%20work%20with%20looping%20structures.%20Looping%20%20structure%20are%20basically%20those%20statements%20which%20are%20to%20be%20executed%20recursively%20%20until%20some%20condition%20is%20fulfilled.%0D%0A%0D%0APHP%20provides%203%20types%20of%20looping%20structures%0D%0A%0D&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<img src="http://www.mygeekpal.com/?ak_action=api_record_view&id=259&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.mygeekpal.com/259/using-loops-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Conditional Statements in PHP &#8211; Learn PHP in 7 Days &#8211; Day #4</title>
		<link>http://www.mygeekpal.com/254/using-conditional-statements-in-php/</link>
		<comments>http://www.mygeekpal.com/254/using-conditional-statements-in-php/#comments</comments>
		<pubDate>Fri, 29 May 2009 07:32:37 +0000</pubDate>
		<dc:creator>irfan07</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mygeekpal.com/?p=254</guid>
		<description><![CDATA[This is one of the most important tutorial for php programming is dealing with Conditional Statements. Let me first illustrate how does this work. For instance whenever you need to check some conditions like whether the value of &#8216;a&#8217; is greater than &#8216;b&#8217; or vice versa you will be in need to use statements as [...]]]></description>
			<content:encoded><![CDATA[<p>This is one of the most important tutorial for php programming is dealing with  Conditional Statements.</p>
<p>Let me first illustrate  how does this work. For instance whenever you need to check some conditions like whether the value of  &#8216;a&#8217; is greater than &#8216;b&#8217; or vice versa you will be in need to use statements as <strong>if, if else, elseif, switch</strong> each have their own specific use and definite purpose to be fulfilled.</p>
<pre class="php" name="code">$a = 10; $b = 5;
if ($a &gt; $b)
{
echo " A is Greater ";
//The controller enters this block only if true
// which in turn executes all the statements in this block
}</pre>
<p>We got 4 conditional statements in PHP and most of other programming languages to have the same operators even the syntax is alike few programming languages might differ but the working is same.</p>
<p>Let me give you the syntax for them</p>
<h4>1. if</h4>
<pre class="php" name="code">if(Condition)
{

}</pre>
<p>Example</p>
<pre class="php" name="code">if ($passwd==$myvalue)
{
echo "Password correct ";
}</pre>
<h4>2. if else</h4>
<pre class="php" name="code">if(Condition)
{

}
else
{

}</pre>
<p>Example</p>
<pre class="php" name="code">if ($passwd==$value)
{
echo " Password correct";
}
else
{
echo " Password Incorrect";
}</pre>
<p>3.elseif</p>
<pre class="php" name="code">if(Condition)
{

}
else if (Condition)
{

}
else if(Condition)
{

}
else
{

}</pre>
<p>Example</p>
<pre class="php" name="code">if ($a&gt;$b AND $a&gt;$c)
{
echo "A is Greater";
}
else if ($b&gt;$a &amp;&amp; $b&gt;$c)
{
echo "B is Greater";
}
else if ($c&gt;$a &amp;&amp; $c&gt;$b)
{
echo "C is Greater";
}
else
{
echo " All Values are equal";
}</pre>
<p>4. Switch</p>
<pre name="code" class="php">switch( expression )

{

case expression:

case expression:

case expression:

default:

}</pre>
<p>Example</p>
<pre name="code" class="php">switch (add)
{

case add: $sum=$a+$b;
echo $sum;

case minus: $sub=$a-$b;
echo $sub;
default: echo " Enter valid options like add or minus";
}</pre>
<p>By these example I think you probably got the idea how to use and when to use such type of conditional statements, well effective utilization of these statements can solve any many logical problems and help create better algorithms.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-spaced shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.mygeekpal.com/254/using-conditional-statements-in-php/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mygeekpal.com/254/using-conditional-statements-in-php/&amp;title=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-designfloat">
			<a href="http://www.designfloat.com/submit.php?url=http://www.mygeekpal.com/254/using-conditional-statements-in-php/&amp;title=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234" rel="nofollow" title="Submit this to DesignFloat">Submit this to DesignFloat</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mygeekpal.com/254/using-conditional-statements-in-php/&amp;t=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234&amp;link=http://www.mygeekpal.com/254/using-conditional-statements-in-php/" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.mygeekpal.com/254/using-conditional-statements-in-php/&amp;title=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234&amp;summary=This%20is%20one%20of%20the%20most%20important%20tutorial%20for%20php%20programming%20is%20dealing%20with%20%20Conditional%20Statements.%0D%0A%0D%0ALet%20me%20first%20illustrate%20%20how%20does%20this%20work.%20For%20instance%20whenever%20you%20need%20to%20check%20some%20conditions%20like%20whether%20the%20value%20of%20%20%27a%27%20is%20greater%20than%20%27b%27%20or%20vice%20versa%20you%20will%20be%20in%20need%20to%20use%20&amp;source=MyGeekPal" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.mygeekpal.com/254/using-conditional-statements-in-php/&amp;title=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.mygeekpal.com/254/using-conditional-statements-in-php/&amp;h=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234&amp;du=http://www.mygeekpal.com/254/using-conditional-statements-in-php/&amp;cn=This%20is%20one%20of%20the%20most%20important%20tutorial%20for%20php%20programming%20is%20dealing%20with%20%20Conditional%20Statements.%0D%0A%0D%0ALet%20me%20first%20illustrate%20%20how%20does%20this%20work.%20For%20instance%20whenever%20you%20need%20to%20check%20some%20conditions%20like%20whether%20the%20value%20of%20%20%27a%27%20is%20greater%20than%20%27b%27%20or%20vice%20versa%20you%20will%20be%20in%20need%20to%20use%20" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.mygeekpal.com/254/using-conditional-statements-in-php/&amp;title=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mygeekpal.com/254/using-conditional-statements-in-php/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234+-+&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mygeekpal.com/254/using-conditional-statements-in-php/&amp;submitHeadline=Using+Conditional+Statements+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%234&amp;submitSummary=This%20is%20one%20of%20the%20most%20important%20tutorial%20for%20php%20programming%20is%20dealing%20with%20%20Conditional%20Statements.%0D%0A%0D%0ALet%20me%20first%20illustrate%20%20how%20does%20this%20work.%20For%20instance%20whenever%20you%20need%20to%20check%20some%20conditions%20like%20whether%20the%20value%20of%20%20%27a%27%20is%20greater%20than%20%27b%27%20or%20vice%20versa%20you%20will%20be%20in%20need%20to%20use%20&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<img src="http://www.mygeekpal.com/?ak_action=api_record_view&id=254&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.mygeekpal.com/254/using-conditional-statements-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Comments in PHP &#8211; Learn PHP in 7 Days &#8211; Day #3</title>
		<link>http://www.mygeekpal.com/248/using-comments-in-php/</link>
		<comments>http://www.mygeekpal.com/248/using-comments-in-php/#comments</comments>
		<pubDate>Fri, 15 May 2009 16:24:45 +0000</pubDate>
		<dc:creator>Atif</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[days]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[line]]></category>
		<category><![CDATA[multi]]></category>
		<category><![CDATA[single]]></category>

		<guid isPermaLink="false">http://www.mygeekpal.com/?p=248</guid>
		<description><![CDATA[Comments are those line which are not executed by the compiler. Comments in PHP are similar to comment in C or C++ or JAVA. Comments are the best way to explain the logic of an application. PHP supports both single line a multiple line comments. Let use see how we can add them. Single Line [...]]]></description>
			<content:encoded><![CDATA[<p>Comments are those line which are not executed by the  compiler. Comments in PHP are similar to comment in C or C++ or JAVA. Comments  are the best way to explain the logic of an application. PHP supports both  single line a multiple line comments. Let use see how we can add them.</p>
<h3>Single Line Comments</h3>
<p>There are 2 ways of writing single line comments in PHP. One  is the classy old way of using double backslash (\\) and the other one is using  the hash (#) symbol. Here&#8217;s the example</p>
<p><code>&lt;?php<br />
echo "Comment Test!"; // Lets  test the commenting feature<br />
echo "The other way"; # echo  "nothing";<br />
// echo "Does this line print?";<br />
# echo "You can sever see this";<br />
?&gt;</code></p>
<p><img class="alignnone size-full wp-image-249" title="4-comments-1" src="http://www.mygeekpal.com/wp-content/uploads/2009/05/4-comments-1.jpg" alt="4-comments-1" width="253" height="111" /></p>
<p>Thatâ€™s out output. I hope you got the meaning of comments</p>
<h3>Multiple Line Comments</h3>
<p>When single lines are not sufficient enough to accommodate  you comments and you need to put a # symbol on each line, then multi line  comments come to your rescue. Using multi line comments is as simple as single  line comments. Just start a multi line comment with /* (front slash followed by  an asterisk) and stuff everything and then close it with */ (asterisk followed  by a front slash).</p>
<p>The example is pretty self explanatory, so lets hit with an  example and see how it works</p>
<p><code>&lt;?php<br />
/* this is a multiline comment<br />
You can use as many lines you want<br />
Just make sure you close it properly */<br />
echo "a multi line comment";<br />
?&gt;</code></p>
<p>As expected, you get the following output for the above code</p>
<p><img class="alignnone size-full wp-image-250" title="4-comments-2" src="http://www.mygeekpal.com/wp-content/uploads/2009/05/4-comments-2.jpg" alt="4-comments-2" width="216" height="105" /></p>
<p>So I think that was all about using comments in PHP.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-spaced shr-bookmarks-bg-caring">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.mygeekpal.com/248/using-comments-in-php/feed" rel="nofollow" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.mygeekpal.com/248/using-comments-in-php/&amp;title=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-designfloat">
			<a href="http://www.designfloat.com/submit.php?url=http://www.mygeekpal.com/248/using-comments-in-php/&amp;title=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233" rel="nofollow" title="Submit this to DesignFloat">Submit this to DesignFloat</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.mygeekpal.com/248/using-comments-in-php/&amp;t=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233&amp;link=http://www.mygeekpal.com/248/using-comments-in-php/" rel="nofollow" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.mygeekpal.com/248/using-comments-in-php/&amp;title=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233&amp;summary=Comments%20are%20those%20line%20which%20are%20not%20executed%20by%20the%20%20compiler.%20Comments%20in%20PHP%20are%20similar%20to%20comment%20in%20C%20or%20C%2B%2B%20or%20JAVA.%20Comments%20%20are%20the%20best%20way%20to%20explain%20the%20logic%20of%20an%20application.%20PHP%20supports%20both%20%20single%20line%20a%20multiple%20line%20comments.%20Let%20use%20see%20how%20we%20can%20add%20them.%0D%0ASingle%20Line%20Comme&amp;source=MyGeekPal" rel="nofollow" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.mygeekpal.com/248/using-comments-in-php/&amp;title=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233" rel="nofollow" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://www.mygeekpal.com/248/using-comments-in-php/&amp;h=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233" rel="nofollow" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-orkut">
			<a href="http://promote.orkut.com/preview?nt=orkut.com&amp;tt=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233&amp;du=http://www.mygeekpal.com/248/using-comments-in-php/&amp;cn=Comments%20are%20those%20line%20which%20are%20not%20executed%20by%20the%20%20compiler.%20Comments%20in%20PHP%20are%20similar%20to%20comment%20in%20C%20or%20C%2B%2B%20or%20JAVA.%20Comments%20%20are%20the%20best%20way%20to%20explain%20the%20logic%20of%20an%20application.%20PHP%20supports%20both%20%20single%20line%20a%20multiple%20line%20comments.%20Let%20use%20see%20how%20we%20can%20add%20them.%0D%0ASingle%20Line%20Comme" rel="nofollow" title="Promote this on Orkut">Promote this on Orkut</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.mygeekpal.com/248/using-comments-in-php/&amp;title=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.mygeekpal.com/248/using-comments-in-php/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233+-+&amp;source=shareaholic" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-yahoobuzz">
			<a href="http://buzz.yahoo.com/submit/?submitUrl=http://www.mygeekpal.com/248/using-comments-in-php/&amp;submitHeadline=Using+Comments+in+PHP+-+Learn+PHP+in+7+Days+-+Day+%233&amp;submitSummary=Comments%20are%20those%20line%20which%20are%20not%20executed%20by%20the%20%20compiler.%20Comments%20in%20PHP%20are%20similar%20to%20comment%20in%20C%20or%20C%2B%2B%20or%20JAVA.%20Comments%20%20are%20the%20best%20way%20to%20explain%20the%20logic%20of%20an%20application.%20PHP%20supports%20both%20%20single%20line%20a%20multiple%20line%20comments.%20Let%20use%20see%20how%20we%20can%20add%20them.%0D%0ASingle%20Line%20Comme&amp;submitCategory=science&amp;submitAssetType=text" rel="nofollow" title="Buzz up!">Buzz up!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

<img src="http://www.mygeekpal.com/?ak_action=api_record_view&id=248&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.mygeekpal.com/248/using-comments-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
