<?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>Helpfolder</title>
	<atom:link href="http://helpfolder.com/feed" rel="self" type="application/rss+xml" />
	<link>http://helpfolder.com</link>
	<description></description>
	<lastBuildDate>Sun, 19 Feb 2012 15:36:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP Exception Handling</title>
		<link>http://helpfolder.com/69/php-exception-handling</link>
		<comments>http://helpfolder.com/69/php-exception-handling#comments</comments>
		<pubDate>Sun, 19 Feb 2012 15:34:15 +0000</pubDate>
		<dc:creator>Mahesh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://helpfolder.com/?p=69</guid>
		<description><![CDATA[PHP like any other programming language has an exception handling feature. You can write your code in a such way that it catches the most obvious exception depending on your programs logic. Exceptions allow you to manage errors much effectively and this is the reason you should consider using them in your program. In this [...]]]></description>
			<content:encoded><![CDATA[<p>PHP like any other programming language has an exception handling feature. You can write your code in a such way that it catches the most obvious exception depending on your programs logic. <span id="more-69"></span>Exceptions allow you to manage errors much effectively and this is the reason you should consider using them in your program. In this tutorial we&#8217;ll take a look at how exceptions in PHP work.</p>
<p>Before you check out the code, let&#8217;s take a look at the three keywords related to the exceptions.</p>
<ul>
<li><strong>Try</strong> &#8211; Inside the try function block we&#8217;re checking if a particular programming logic triggers an exception.</li>
<li><strong>Throw</strong> &#8211; If the program finds an exception in try block we throw an exception using throw keyword.</li>
<li><strong>Catch</strong> &#8211; This is the block where an object is created with exception information.</li>
</ul>
<p>Check the below code to see how an exception handling program works.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> php try <span style="color: #009900;">&#123;</span>     <span style="color: #000088;">$checkvar</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">'testing error'</span><span style="color: #339933;">;</span>     <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #000088;">$checkvar</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'ine is skipped by compiler as it moves directly in catch block after throwing an exception'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Found an exception: '</span><span style="color: #339933;">,</span>
<span style="color: #000088;">$e</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getMessage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Exception program demo;
?&gt;</span></pre></div></div>

<p>In try block we&#8217;re creating a variable and throwing a new exception when compiler finds it. Any line after the throw keyword is not executed as the entire block is skipped to catch. So any code below the throw keyword is skipped. Inside catch block an exception is thrown and you get the error message printed. After this the last echo statement is printed on webpage.</p>
<p>Points to Remember:</p>
<ul>
<li>An exception can be caught or thrown with the help of php block.</li>
<li>There should be atleast one catch block for corresponding try block.</li>
<li>Exceptions can be thrown or rethrown within a catch block.</li>
</ul>
<p>You can use the exception handling while working with <a href="http://helpfolder.com/65/php-file-handling">php file handling</a> or network connection related programs. I hope this helps you to understand the exception handling in php. If you have any questions, suggestions related to this tutorial, feel free to comment. If the comments are expired on this post, feel free to use twitter to ask me.</p>
]]></content:encoded>
			<wfw:commentRss>http://helpfolder.com/69/php-exception-handling/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP File Handling</title>
		<link>http://helpfolder.com/65/php-file-handling</link>
		<comments>http://helpfolder.com/65/php-file-handling#comments</comments>
		<pubDate>Wed, 08 Feb 2012 21:36:21 +0000</pubDate>
		<dc:creator>Mahesh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://helpfolder.com/?p=65</guid>
		<description><![CDATA[File handling is very important task that every php developer needs to learn. PHP offers you simple way to manipulate files. You can easily read, write, append or delete data in files. This comes in handy when you use PHP regex with your files. In file handling you&#8217;re basically doing following simple steps. Create a [...]]]></description>
			<content:encoded><![CDATA[<p>File handling is very important task that every php developer needs to learn. PHP offers you simple way to manipulate files. You can easily read, write, append or delete data in files. This comes in handy when you use<a href="http://helpfolder.com/56/php-regular-expressions"> PHP regex</a> with your files. <span id="more-65"></span></p>
<p>In file handling you&#8217;re basically doing following simple steps. </p>
<ul>
<li>Create a file.</li>
<li>Assign an object to open the file. </li>
<li>Read or write on the file.</li>
<li>Close the file.</li>
</ul>
<p>These four steps remain the same for every file management program in php or any other language. You just have to insert any other optional logic combining with these four steps. So let&#8217;s take a look at how to create a file using php program. </p>
<p><strong>The fopen() and fclose() function</strong></p>
<p>Let&#8217;s start with creating the file. In this example we&#8217;re going to assign file object to a variable. After that we&#8217;re going to open the file for writing with fopen() function and in this process if php fails to find the file, It&#8217;ll process the error message in the die() function. At the end we&#8217;re calling fclose() function to close the file.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> php
<span style="color: #000088;">$dm_f</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;demophp.txt&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dm_file</span><span style="color: #339933;">=</span><span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dm_f</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;can't find file&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dm_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
? <span style="color: #339933;">&gt;</span></pre></div></div>

<p>Note that we&#8217;re using the access mode &#8220;w&#8221; here which means we&#8217;re opening the file for write operations. You can use &#8220;r&#8221; mode if you wish to just read the file. In case of write only data is erased from the previous write and the new data is written on the file. You can use &#8220;a&#8221; append mode for appending the data to the file. </p>
<p><strong>Writing to File</strong></p>
<p>Check out the following code :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ? php
<span style="color: #000088;">$dm_f</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;demophp.txt&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dm_file</span><span style="color: #339933;">=</span><span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dm_f</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;can't find file&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dm_fw</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;this is new text<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dm_file</span><span style="color: #339933;">,</span><span style="color: #000088;">$dm_fw</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dm_fw</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;this is another one<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dm_file</span><span style="color: #339933;">,</span><span style="color: #000088;">$dm_fw</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dm_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
? <span style="color: #339933;">&gt;</span></pre></div></div>

<p>In Line 1: we&#8217;re creating a demophp.txt file and in Line 2: we&#8217;re creating file instance to write on our demophp.txt file. In Line 3: we&#8217;re creating a string that we&#8217;re going to add with the help of fwrite() function into our demophp file. Every time we created string, we used fwrite() function to pass it to the text file and at the end we closed the file using fclose() function. </p>
<p>You can also experiment with the access mode &#8216;a&#8217;. Why? In case of making log files or creating any file that adds the data on regular period will need both previous and current data and in that case append is useful. </p>
<p><strong>Reading a File</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ? php
<span style="color: #000088;">$dm_f</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;demophp.txt&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dm_file</span><span style="color: #339933;">=</span><span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dm_f</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;can't find file&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dm_fr</span><span style="color: #339933;">=</span><span style="color: #990000;">fread</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dm_file</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dm_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$dm_fr</span><span style="color: #339933;">;</span>
? <span style="color: #339933;">&gt;</span></pre></div></div>

<p>Reading a file follows the same format. You&#8217;re going to create a file then open that file with read access mode. By using fread() function you&#8217;re going to read the instance of file object by explicitly mentioning how many characters you want to read. In our example we&#8217;re using 100 as a fixed number. At the end we&#8217;re closing the file and then echoing the data read by variable.</p>
<p><strong>Deleting the File unlike function()</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>  ?php
<span style="color: #000088;">$dmf</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;thisfile.txt&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dmf</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
? <span style="color: #339933;">&gt;</span></pre></div></div>

<p>Just be careful when you use unlink function as it deletes the content of the file from your server or disk. Deleting is very simple, you just have to pass the file object to the unlink() function. Just make sure you create another program to create the file and verify the existence before you use unlink() function. That way results are noticeable to you. </p>
<p>Hope this tutorial helps you to manipulate files using php. Feel free to let me know your feedback in comments. </p>
]]></content:encoded>
			<wfw:commentRss>http://helpfolder.com/65/php-file-handling/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Codeigniter Setup on Xampp and Uniform Server</title>
		<link>http://helpfolder.com/60/codeigniter-setup-on-xampp-and-uniform-server</link>
		<comments>http://helpfolder.com/60/codeigniter-setup-on-xampp-and-uniform-server#comments</comments>
		<pubDate>Sun, 05 Feb 2012 00:45:17 +0000</pubDate>
		<dc:creator>Mahesh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://helpfolder.com/?p=60</guid>
		<description><![CDATA[Learn How to Setup Codeigniter with Xampp and Uniform Server. Codeigniter is one of the popular PHP framework that is suitable for many new php programmers. Codeigniter is lightweight and is relatively easy to understand php framework compared to cakephp and other frameworks. In this tutorial, we will setup codeigniter and get things running with [...]]]></description>
			<content:encoded><![CDATA[<p>Learn How to Setup Codeigniter with Xampp and Uniform Server. Codeigniter is one of the popular PHP framework that is suitable for many new php programmers. Codeigniter is lightweight and is relatively easy to understand php framework compared to cakephp and other frameworks. In this tutorial, we will setup codeigniter and get things running with XAMPP and Uniform server. <span id="more-60"></span>I am explaining codeigniter setup using both of these web servers just so that if anyone wants to use one of these will find it easy to setup. </p>
<p>We’re covering both webservers here so skip the steps of webserve which doesn’t apply to you. </p>
<p><strong>Xampp and Codeigniter Setup</strong>: </p>
<p>First thing we are going to do is setup Xampp for those who want to use codeigniter with xampp. So go ahead and download either portable version or developer version of <a href="http://www.apachefriends.org/en/xampp.html">xampp</a>. Install it in the directory (and drive) as per your choice. Once you copy all the files of xampp in directory, find the start.bat file to start the xampp server. You can also click on xampp control panel to manually start xampp services. </p>
<p>Second Download <a href="http://codeigniter.com">Codeigniter</a> and extract the files in “htdocs” folder of xampp. You can make the path something like this : <em>/htdocs/codeigniter or /htdocs/ci</em>. You can also rename the codeigniter folder as per your choice. </p>
<p>You can start the server and test the codeigniter setup at <em>http://localhost/codeigniter</em> or if you have renamed the codeigniter folder to something else, use that name. </p>
<p><strong>Uniform Server and Codeigniter Setup</strong>: </p>
<p><a href="http://www.uniformserver.com/">Unifrom server</a> is very easy to setup and is much better to manage sometimes compared to xampp. You can download uniform server and extrac it to the drive (and in turn directory) of your choice. Once extracted, navigate to the following directory: <em>\UniServer\udrive\www</em>. Inside the ‘www’ folder you have to extract the codeigniter. You can rename codeigniter to something simple if you wish that will definitely help while coding multiple codeigniter projects. </p>
<p>Start the server by going to following address: <em>http://localhost/CI</em>. </p>
<p>You will see the image as shown below in the screenshot.<br />
<img src="http://helpfolder.com/wp-content/uploads/2012/02/codeigniter_uniform_server-300x143.jpg" alt="" title="codeigniter_uniform_server" width="300" height="143" class="aligncenter size-medium wp-image-61" /></p>
<p>If you want to create your own welcome message for the application, you should edit the following file. </p>
<p><em>application/views/welcome_message.php</em></p>
<p>This completes our simple codeigniter setup tutorial. In next few tutorials, we will see how to setup dynamic websites and later in more advanced tutorials we will check out how to create simple blogs and forums. I hope this simple tutorial helps you to setup codeigniter on your development server. </p>
]]></content:encoded>
			<wfw:commentRss>http://helpfolder.com/60/codeigniter-setup-on-xampp-and-uniform-server/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Regular Expressions</title>
		<link>http://helpfolder.com/56/php-regular-expressions</link>
		<comments>http://helpfolder.com/56/php-regular-expressions#comments</comments>
		<pubDate>Thu, 26 Jan 2012 18:11:04 +0000</pubDate>
		<dc:creator>Mahesh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://helpfolder.com/?p=56</guid>
		<description><![CDATA[Regular expressions are the patterns that allow you to processs text based on certain requirement. This in turn produces the sequence or pattern of text that is based on pattern-matching as per developers needs. You can do a lot of things using regular expressions. For example, you can filter our the text in uppercase or [...]]]></description>
			<content:encoded><![CDATA[<p>Regular expressions are the patterns that allow you to processs text based on certain requirement. This in turn produces the sequence or pattern of text that is based on pattern-matching as per developers needs. You can do a lot of things using regular expressions. <span id="more-56"></span>For example, you can filter our the text in uppercase or replace the word with something else, match the group of text and filter the content. There are plenty of other ways to use the regular expression as per your needs.</p>
<p>PHP allows you to use two types of regular expressions.</p>
<ul>
<li>POSIX Regular Expressions</li>
<li>PERL Style Regular Expressions</li>
</ul>
<p>I suggest you to follow the PERL Compatible Regular expressions as they&#8217;re widely used. There isn&#8217;t much difference between POSIX and PCRE but you&#8217;ve to learn separately to know them better.</p>
<p>There are ways to explain the valid and invalid patterns of regular expressions. I suggest you to use the examples to learn about these valid patterns. This is the reason I am not going to explain you every little expression, Instead you&#8217;ll learn from the examples posted here.</p>
<p>Let&#8217;s take a look at important perl compatible regular expression functions.</p>
<p><strong>preg_match()</strong> : This function performs a regular expression match. Check the following code to see it in action.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> php
<span style="color: #000088;">$str</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;this is demo&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$str1</span><span style="color: #339933;">=</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/this/&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$str2</span><span style="color: #339933;">=</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/that/&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$str1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$str2</span><span style="color: #339933;">;</span>
? <span style="color: #339933;">&gt;</span></pre></div></div>

<p>Check the output and you&#8217;ll see that it shows 1 and 0. Here value 1 means we have found match and 0 means that there is no match. You can process much more complex data with the help of loops and reg operators.</p>
<p><strong>preg_replace()</strong>: This function performs regular expression search and replace operation. See the following code so that you get idea of how preg_replace() works.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> php
<span style="color: #000088;">$data</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Here is some simple text&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$find</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/is/&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$replace</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;is our&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$find</span><span style="color: #339933;">,</span><span style="color: #000088;">$replace</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
? <span style="color: #339933;">&gt;</span></pre></div></div>

<p>There are two more optional arguments that you can pass to the preg_replace() to count the replacements and also to restrict the number of replacements of text.</p>
<p><strong>preg_split()</strong>: This function takes your input and then split the input into multiple arrays. The value in array is dependent on your operator usage for spliting the text. PREG_SPLIT_NO_EMPTY argument ensures that no empty results are passed to the output of array. Check the following code on preg_split and see how we&#8217;re spliting the two statements that are separated with dot.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> php
<span style="color: #000088;">$data</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Here is some simple text. Run the program&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$prodata</span><span style="color: #339933;">=</span><span style="color: #990000;">preg_split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\./'</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>PREG_SPLIT_NO_EMPTY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$prodata</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
? <span style="color: #339933;">&gt;</span></pre></div></div>

<p>Check the output and you&#8217;ll see that it splits the sentences in two arrays starting from [0].</p>
<p>This was just short introduction on regular expressions in php. You can read more about regular expressions in general from wikipedia. If you&#8217;re python programmer then do read <a href="http://onecore.net/regular-expressions-in-python.htm">python regular expressions</a> tutorial.</p>
<p>Feel free to let me know your suggestions and feedback on this tutorial. I would love to improve if there are any constructive criticisms in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://helpfolder.com/56/php-regular-expressions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Solution to the Project Euler Problem 1</title>
		<link>http://helpfolder.com/48/php-solution-to-the-project-euler-problem-1</link>
		<comments>http://helpfolder.com/48/php-solution-to-the-project-euler-problem-1#comments</comments>
		<pubDate>Fri, 09 Dec 2011 20:30:18 +0000</pubDate>
		<dc:creator>Mahesh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://helpfolder.com/?p=48</guid>
		<description><![CDATA[This is one of the easiest problem in the project euler archive. You can perform this problem in any language of your choice. As this site is specifically for web developers so i&#8217;m focusing on php for this post. You can change the code to get answer in C, C++ or any other language of [...]]]></description>
			<content:encoded><![CDATA[<p>This is one of the easiest problem in the project euler archive. You can perform this problem in any language of your choice. As this site is specifically for web developers so i&#8217;m focusing on php for this post. You can change the code to get answer in C, C++ or any other language of your choice. <span id="more-48"></span>Depending on your language, few changes will be there but that&#8217;s upto you to fix. As this tutorial deals with the PHP code, I can tell you for sure that this code works. </p>
<p>You can check the problem <a href="http://projecteuler.net/problem=1">here</a>. It says :</p>
<blockquote><p>If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.</p>
<p>Find the sum of all the multiples of 3 or 5 below 1000.</p></blockquote>
<p><strong>Thought Process</strong> &#8211; If you take a look at this problem you&#8217;ll observe that only numbers that are multiples of 3 and 5 are &#8211; 3, 5,6,9. You have to repeat this process for 1000 numbers in your program. Yes, you guessed it right we&#8217;re going to use loop in our program. We&#8217;re going to run a loop that counts upto 1000. We also need to check for the condition that checks the number is divisble by 3 and 5 and remainder is 0. In such case we&#8217;re going to use if condition inside our for loop to filter those numbers and it in our another variable that keep the sum.</p>
<p>You can see this in action in following code:</p>
<p><strong>Code</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$j</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$k</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$j</span><span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span><span style="color: #000088;">$j</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$j</span><span style="color: #339933;">%</span><span style="color:#800080;">3</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">||</span><span style="color: #000088;">$j</span><span style="color: #339933;">%</span><span style="color:#800080;">5</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000088;">$k</span><span style="color: #339933;">+=</span><span style="color: #000088;">$j</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;The sum of Multiples of 3 and 5 is: &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$k</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This is very simple problem and I guess you should attempt it as much as possible before looking at this site for answer. If you manage to learn it in php, try to impement the logic in python or C# or C++. This will improve your language learning and logic too. </p>
]]></content:encoded>
			<wfw:commentRss>http://helpfolder.com/48/php-solution-to-the-project-euler-problem-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Loops</title>
		<link>http://helpfolder.com/45/php-loops</link>
		<comments>http://helpfolder.com/45/php-loops#comments</comments>
		<pubDate>Thu, 08 Dec 2011 08:19:26 +0000</pubDate>
		<dc:creator>Mahesh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://helpfolder.com/?p=45</guid>
		<description><![CDATA[PHP like any other programming language makes use of loops to perform particular task repeatedly. You can use loops to perform tasks that are supposed to be executed if certain condition is met upto particular period. Like this there are many ways to use loops while programming with php. In this tutorial we&#8217;re going to [...]]]></description>
			<content:encoded><![CDATA[<p>PHP like any other programming language makes use of loops to perform particular task repeatedly. You can use loops to perform tasks that are supposed to be executed if certain condition is met upto particular period. <span id="more-45"></span>Like this there are many ways to use loops while programming with php. In this tutorial we&#8217;re going to take a look at ways with which we can use loops in php. </p>
<p>Loops always check for the particular condition before executing particular task. If the condition is true or false, it&#8217;ll generate the output for the loop. </p>
<p><strong>While Loop</strong></p>
<p>Let&#8217;s start learning with &#8216;while&#8217; loop first. Check the basic syntax of the while loop:</p>
<p><strong>Code</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>condition<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You&#8217;ve to place some condition in order to execute while loop. If your condition evalutes to true, the loop will execute or lese it&#8217;ll not.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;br/&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong><br />
For Loop</strong></p>
<p>For loop allows you to have control over initiation, condition and increment in the same line. Like while loop it also processes a block of code until a statement becomes false. </p>
<p><strong>Syntax Code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>condition<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>In this code our condition statement contains &#8211; <em>initiation, condition and increment</em>. You can skip increment if you want to use it inside the block of code. Either way with increment is fine with for loop. Check the modification in code made  for &#8211; &#8220;for loop&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>$<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;=</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;br/&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>FOREACH Loop</strong></p>
<p>A <em>foreach</em> loop is used when you&#8217;re dealing with arrays. It executes a block of code as long as loop uses all the values of arrays specified in the condition are used. Once those values are used then loop ends. So there is no need to explicitly add the increment for the arrays. </p>
<p><strong>Syntax</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$j</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>In this loop, we&#8217;re creating an array to be used <em>foreach</em> loop. This array specifies a particular set of values upto which the loop will execute.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$k</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;br/&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>As you can see in the output, this loop executes till all the values in array are used. Once used you can see that loop ends. </p>
<p>These three are the types of loops that you&#8217;re going to use while programming in php. Hope this tutorial helps to you and if you have any suggestion or feedback on these tutorials, feel free to let us know. </p>
]]></content:encoded>
			<wfw:commentRss>http://helpfolder.com/45/php-loops/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Redirect Users using PHP</title>
		<link>http://helpfolder.com/43/how-to-redirect-users-using-php</link>
		<comments>http://helpfolder.com/43/how-to-redirect-users-using-php#comments</comments>
		<pubDate>Wed, 07 Dec 2011 15:55:26 +0000</pubDate>
		<dc:creator>Mahesh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://helpfolder.com/?p=43</guid>
		<description><![CDATA[There are many instances where redirection saves a lot of time. You can create a redirection to forwards users to a page which is translated for their locale. You can use redirection for affiliate link and you can also use redirection to avoid non-local folks to English version of your site. You can also redirect [...]]]></description>
			<content:encoded><![CDATA[<p>There are many instances where redirection saves a lot of time. You can create a redirection to forwards users to a page which is translated for their locale. You can use redirection for affiliate link and you can also use redirection to avoid non-local folks to English version of your site. <span id="more-43"></span>You can also redirect users from 404 page to homepage in order to help in SEO. There are many other uses of redirection script, it&#8217;s all upto you to use it in a way that gets your job done. </p>
<p>PHP redirects being a server side script works on all browsers and you don&#8217;t have to worry about browser standards. Redirection is quick and distraction free as you&#8217;re not wasting time by showing them some demo page in between the redirection. In this tutorial we&#8217;re assuming that you&#8217;re creating redirection on your 404 page. You can use the following code to redirect search engines and users to homepage. </p>
<p><strong>Code</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location:http://yahoo.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You can replace the yahoo with some other page of your site. You can also use specific 404 page or archive page which most of the websites use to redirect users. Archive page or sitemap pages are more useful as they let visitors make decision about where to visit next from the redirected page. </p>
<p><strong>Note:</strong> While running this php page make sure you&#8217;re not placing this code in < body > tag. Make this page purely php page without any other code in between and before or after the code. This should be the only code that needs to be executed in order for this example to work. If you&#8217;re using php designer 7 onwards then you may notice that redirection example may not work in the IDE. For some strange reasons it doesn&#8217;t work inside IDE. </p>
]]></content:encoded>
			<wfw:commentRss>http://helpfolder.com/43/how-to-redirect-users-using-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Disable Right Click on Website</title>
		<link>http://helpfolder.com/38/how-to-disable-right-click-on-website</link>
		<comments>http://helpfolder.com/38/how-to-disable-right-click-on-website#comments</comments>
		<pubDate>Mon, 05 Dec 2011 21:26:23 +0000</pubDate>
		<dc:creator>Mahesh</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://helpfolder.com/?p=38</guid>
		<description><![CDATA[Learn How to disable right click menu on any website in this tutorial. There are some people on the web who scrape your content and use it on their own website without taking permission. In such cases they don&#8217;t give credit to original author and also they don&#8217;t care who is the original source. Such [...]]]></description>
			<content:encoded><![CDATA[<p>Learn How to disable right click menu on any website in this tutorial. There are some people on the web who scrape your content and use it on their own website without taking permission. In such cases they don&#8217;t give credit to original author and also they don&#8217;t care who is the original source. <span id="more-38"></span>Such type of plagiarists are hard to deal with as they&#8217;re going to deny every form of communication to take down the content. In such a case you should consider protecting your content and feeds from such scrapers. </p>
<p>In this tutorial we&#8217;ll see how to disable the the right click browser specific menu. As this JavaScript is taken from <a href="http://www.dynamicdrive.com/dynamicindex9/noright3.htm">dynamic drive</a>, credit of this code snippet goes to renigade (dynamic drive). </p>
<p><strong>Disable Right Click on Static HTML Sites</strong></p>
<p>For static sites with limited web pages should add the following code inside the html page. Make sure you add this code before < / body > tag of the html page.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script language<span style="color: #339933;">=</span>JavaScript<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;!--</span>
<span style="color: #003366; font-weight: bold;">var</span> message<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">///////////////////////////////////</span>
<span style="color: #003366; font-weight: bold;">function</span> clickIE<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">all</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>return <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> clickNS<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">if</span> 
<span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">layers</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #339933;">&amp;&amp;!</span>document.<span style="color: #660066;">all</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">which</span><span style="color: #339933;">==</span><span style="color: #CC0000;">2</span><span style="color: #339933;">||</span>e.<span style="color: #660066;">which</span><span style="color: #339933;">==</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>return <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">layers</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>document.<span style="color: #660066;">captureEvents</span><span style="color: #009900;">&#40;</span>Event.<span style="color: #660066;">MOUSEDOWN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>document.<span style="color: #660066;">onmousedown</span><span style="color: #339933;">=</span>clickNS<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>document.<span style="color: #660066;">onmouseup</span><span style="color: #339933;">=</span>clickNS<span style="color: #339933;">;</span>document.<span style="color: #660066;">oncontextmenu</span><span style="color: #339933;">=</span>clickIE<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
document.<span style="color: #660066;">oncontextmenu</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> <span style="color: #003366; font-weight: bold;">Function</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;return false&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #006600; font-style: italic;">// --&gt; </span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p><strong>Disable Right Click on WordPress Blog</strong></p>
<p>In case of wordpress you can either edit header.php or footer.php of your theme OR you can use text widget in sidebar or footer to add this code. If you change theme, just add the widget back again to enable the script or else you can again modify the footer.php or header.php of theme.<br />
<div id="attachment_40" class="wp-caption aligncenter" style="width: 303px"><img src="http://helpfolder.com/wp-content/uploads/2011/12/Wordpress_Widget-293x300.jpg" alt="" title="Wordpress_Widget" width="293" height="300" class="size-medium wp-image-40" /><p class="wp-caption-text">Adding Javascript Code in Text Widget of WordPress</p></div></p>
<p><strong>Disable Right Click on Blogger Blog</strong></p>
<p>You can add HTML widget in sidebar and then add the above code. This will eliminate the need to updating the code if you change theme. This sidebar usually remains consistent even after theme changes so you&#8217;ll definitely benefit by adding the code in html widget. </p>
<p><strong>Tumblr, WordPress.com, Joomla and Drupal</strong></p>
<ul>
<li>WordPress.com allows you to use add TEXT widget in sidebar which you can use to add this javascript snippet. </li>
<li>Tumblr is an online CMS and in order to make the changes you have to edit the theme of tumblr. So after every theme changes you have to add this javascript snippet into theme. </li>
<li>Joomla and Drupal has theme and templates feature which you can use to edit the themes. Adding this javascript snippet in your theme is very easy if you&#8217;re already using such a complicated CMS like drupal (or joomla).</li>
</ul>
<p>If you&#8217;re using any other content management system like textpattern, expression engine etc. then you have to ask for help in respective community forums. </p>
]]></content:encoded>
			<wfw:commentRss>http://helpfolder.com/38/how-to-disable-right-click-on-website/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Functions Tutorial</title>
		<link>http://helpfolder.com/34/php-functions-tutorial</link>
		<comments>http://helpfolder.com/34/php-functions-tutorial#comments</comments>
		<pubDate>Sat, 03 Dec 2011 18:44:30 +0000</pubDate>
		<dc:creator>Mahesh</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://helpfolder.com/?p=34</guid>
		<description><![CDATA[A function is used in almost every programming language to reduce excessive code and for effective code re-usability. In some programming languages function is called as method. In almost every programming language they&#8217;re used to perform particular task on regular basis. This way it saves time of programmer and code also becomes more readable. In [...]]]></description>
			<content:encoded><![CDATA[<p>A function is used in almost every programming language to reduce excessive code and for effective code re-usability. In some programming languages function is called as method. In almost every programming language they&#8217;re used to perform particular task on regular basis. This way it saves time of programmer and code also becomes more readable. <span id="more-34"></span></p>
<p>In this tutorial we&#8217;re going to take a look at function syntax and various ways to use functions. </p>
<p><strong>Syntax</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> name_of_function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You can follow camel-case convention for the function name. You can also use underscore for the function name but never start it with number or else compiler will flag error. </p>
<p>Keep these points in mind while writing functions -</p>
<ul>
<li>Start your function with the keyword function.</li>
<li>Function should be declared first before using in your program.</li>
<li>Make sure the function name is correctly used in a program.</li>
</ul>
<p><strong>How to Use PHP function</strong></p>
<p>We have already created our first function so let&#8217;s take a quick look at how we can use it in our program. One thing to note that you have to declare the function before you use it. You can also add the function by import function if you want in your program.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> hello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;hello&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;this is function demo&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>
hello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Parametrized Functions</strong></p>
<p>You can pass value to your functions from outside the functions. You can then use the value to process in your function or just use them to print out on web page.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000000; font-weight: bold;">function</span> apple<span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;no of apples are&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$num</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
apple<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You can also process the value and show results back to the user.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">function</span> apple<span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$num</span><span style="color: #339933;">+=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;no of apples after adding 1 more in the basket :&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$num</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
apple<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>That&#8217;s it. You now know how to use functions in php. You can practice using functions with some demo programs. There are many home work assignments out there that you can see for more php function examples. Hope this helps you. Feel free to ask questions, suggest a feature, point errors. Don&#8217;t forget to bookmark or share this site in any social network site of your choice. </p>
]]></content:encoded>
			<wfw:commentRss>http://helpfolder.com/34/php-functions-tutorial/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Use HTML Forms With PHP</title>
		<link>http://helpfolder.com/32/how-to-use-html-forms-with-php</link>
		<comments>http://helpfolder.com/32/how-to-use-html-forms-with-php#comments</comments>
		<pubDate>Fri, 02 Dec 2011 19:06:19 +0000</pubDate>
		<dc:creator>Mahesh</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://helpfolder.com/?p=32</guid>
		<description><![CDATA[Some HTML forms pass data from one page to another without the use of database. You can use php to enhance your HTML forms by making sure that these forms are processed properly. For example if you want some condition to be fulfilled before processing the form then it is possible to do so with [...]]]></description>
			<content:encoded><![CDATA[<p>Some HTML forms pass data from one page to another without the use of database. You can use php to enhance your HTML forms by making sure that these forms are processed properly. For example if you want some condition to be fulfilled before processing the form then it is possible to do so with php.<span id="more-32"></span> In this tutorial we&#8217;re going to process out data from one form to another static page by using php. </p>
<p>In this tutorial we&#8217;re going to create a page that passes two variables to another page via forms. Variables &#8220;toys&#8221; and &#8220;game&#8221; are the ones we&#8217;re going to pass.We&#8217;re going to add these in the form of attributes in the form. These two variables will be displaying a value that user selects in first page. Let&#8217;s create a simple HTML form with some options -</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;body&gt;
&lt;h3&gt;Select an Option&lt;/h4&gt;
&lt;form action=&quot;toys.php&quot; method=&quot;post&quot;&gt;
&lt;select name=&quot;game&quot;&gt;
&lt;option&gt;kite&lt;/option&gt;
&lt;option&gt;yo yo&lt;/option&gt;
&lt;option&gt;beyblade&lt;/option&gt;
&lt;/select&gt;
How many : &lt;input name=&quot;toys&quot; type=&quot;text&quot;/&gt;
&lt;input type=&quot;submit&quot;/&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>If you read the code carefully then you&#8217;ll notice that field name &#8220;game&#8221; and &#8220;toys&#8221; are going to be important here. As they&#8217;re the items that we&#8217;re going to pass to other page.<br />
<strong><br />
Code toys.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;body&gt;
&lt;?php 
$toys=$_post['toys'];
$game=$_post['game'];
echo &quot;You want&quot;.toys.&quot; &quot;.$game.&quot;;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>You can upload these two files on your webserver and execute it to see if they&#8217;re showing you the right output. You can test this on your own if you have xampp server on your desktop.</p>
]]></content:encoded>
			<wfw:commentRss>http://helpfolder.com/32/how-to-use-html-forms-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

