<?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>WildPHP &#187; Basics</title>
	<atom:link href="http://www.wildphp.com/category/basics/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wildphp.com</link>
	<description>Free Video Tutorials, Scripts, and Articles for You!</description>
	<lastBuildDate>Tue, 11 May 2010 01:24:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Final Code Challenge</title>
		<link>http://www.wildphp.com/basics/final-code-challenge/</link>
		<comments>http://www.wildphp.com/basics/final-code-challenge/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 05:46:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=178</guid>
		<description><![CDATA[Looks like our teaching time is coming to a close. You have gone from not knowing what PHP is to well versed. You must pass one final test before you are a true PHP Master!
]]></description>
			<content:encoded><![CDATA[<p>Looks like our teaching time is coming to a close. You have gone from not knowing what PHP is to well versed. You must pass one final test before you are a true PHP Master!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/final-code-challenge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grabbing $_GET</title>
		<link>http://www.wildphp.com/basics/grabbing-get/</link>
		<comments>http://www.wildphp.com/basics/grabbing-get/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 05:43:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=174</guid>
		<description><![CDATA[Ah, another one of those choose one or the other they both do the same thing. We can use the same HTML code, but change the method to GET.


&#60;html&#62;
&#60;head&#62;
&#60;title&#62;Flipping Forms Tutorial&#60;/title&#62;
&#60;/head&#62;
&#60;body&#62;
The following is a form: &#60;br/&#62;

&#60;form action=&#34;index.php&#34; method=&#34;get&#34;&#62;
What is your favorite book?: &#60;input type=&#34;text&#34; name=&#34;book&#34; /&#62;&#60;br/&#62;
What is your favorite movie?: &#60;input type=&#34;text&#34; name=&#34;movie&#34; /&#62;&#60;br/&#62;
What is [...]]]></description>
			<content:encoded><![CDATA[<p>Ah, another one of those choose one or the other they both do the same thing. We can use the same HTML code, but change the method to <strong>GET</strong>.</p>
<pre class="brush: html">

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Flipping Forms Tutorial&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
The following is a form: &lt;br/&gt;

&lt;form action=&quot;index.php&quot; method=&quot;get&quot;&gt;
What is your favorite book?: &lt;input type=&quot;text&quot; name=&quot;book&quot; /&gt;&lt;br/&gt;
What is your favorite movie?: &lt;input type=&quot;text&quot; name=&quot;movie&quot; /&gt;&lt;br/&gt;
What is your favorite website?: &lt;input type=&quot;text&quot; name=&quot;website&quot; /&gt;&lt;br/&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Now the difference between GET and POST is a matter of visibility. When we hit the submit the POST data &#8220;magically&#8221; goes to the next page. With GET the data is put on the end of URL. When you hit submit you should see something like this on the end of your URL <strong>?book=Harry+Potter&amp;movie=Star+Wars&amp;website=WildPHP+of+Course!</strong> .To print out the variables like last time we just use $_GET instead of $_POST:</p>
<p>Printed Results:</p>
<p>&lt;?php<br />
//Print out our GET Data<br />
echo &#8220;Favorite Book: &#8220;.$_GET["book"];<br />
echo &#8220;Favorite Movie: &#8220;.$_GET["movie"];<br />
echo &#8220;Favorite Movie: &#8220;.$_GET["website"];<br />
?&gt;</p>
<p>Sample Output:</p>
<blockquote><p>Favorite Book: Harry Potter<br />
Favorite Movie: Star Wars<br />
Favorite Website: WildPHP of Course!</p></blockquote>
<p>Now that the data is viewable in the URL it probably won&#8217;t be the best idea to send passwords or sensitive data via GET. GET however can be very useful because we can pass information to PHP without having to fill out a form. If you look above at the URL you are at right now you can see GET in use. Using the info in the URL, PHP knows what post to pull up.</p>
<p>If you want to create a GET variable in a URL just follow this simple format: <strong>?varname=value&amp;varname2=value2.</strong> Notice that it always starts with a question mark, and additional values can be added with an ampersand(&amp;).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/grabbing-get/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pasting $_POST</title>
		<link>http://www.wildphp.com/basics/pasting-post/</link>
		<comments>http://www.wildphp.com/basics/pasting-post/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 05:13:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=176</guid>
		<description><![CDATA[In the last tutorial we brushed up on our HTML skills. Lets take the code from the last tutorial, and make a small edit.


&#60;html&#62;
&#60;head&#62;
&#60;title&#62;Flipping Forms Tutorial&#60;/title&#62;
&#60;/head&#62;
&#60;body&#62;
The following is a form: &#60;br/&#62;

&#60;form action=&#34;index.php&#34; method=&#34;post&#34;&#62;
What is your favorite book?: &#60;input type=&#34;text&#34; name=&#34;book&#34; /&#62;&#60;br/&#62;
What is your favorite movie?: &#60;input type=&#34;text&#34; name=&#34;movie&#34; /&#62;&#60;br/&#62;
What is your favorite website?: &#60;input type=&#34;text&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>In the last tutorial we brushed up on our HTML skills. Lets take the code from the last tutorial, and make a small edit.</p>
<pre class="brush: html">

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Flipping Forms Tutorial&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
The following is a form: &lt;br/&gt;

&lt;form action=&quot;index.php&quot; method=&quot;post&quot;&gt;
What is your favorite book?: &lt;input type=&quot;text&quot; name=&quot;book&quot; /&gt;&lt;br/&gt;
What is your favorite movie?: &lt;input type=&quot;text&quot; name=&quot;movie&quot; /&gt;&lt;br/&gt;
What is your favorite website?: &lt;input type=&quot;text&quot; name=&quot;website&quot; /&gt;&lt;br/&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>If you didn&#8217;t notice the slight change I made was <strong>method=&#8221;post&#8221;</strong>. This specifies the type of data our form should send. Now on to the PHP. Putting some text in box and hitting submit is not going to do us much good, so let&#8217;s capture it and print it out. Put this PHP code under the &lt;/form&gt; tag.</p>
<pre class="brush: php">

Printed Results:&lt;br/&gt;

&lt;?php
//Print out our Post Data
echo &quot;Favorite Book: &quot;.$_POST[&quot;book&quot;].&quot;&lt;br/&gt;&quot;;
echo &quot;Favorite Movie: &quot;.$_POST[&quot;movie&quot;].&quot;&lt;br/&gt;&quot;;
echo &quot;Favorite Website: &quot;.$_POST[&quot;website&quot;].&quot;&lt;br/&gt;&quot;;
?&gt;
</pre>
<p>Sample Output:</p>
<blockquote><p>Favorite Book: Harry Potter<br />
Favorite Movie: Star Wars<br />
Favorite Website: WildPHP of Course!</p></blockquote>
<p>As you can see from the code we get the post data and print it out once you hit submit. The simple $_POST["var name"] statement allows us to do that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/pasting-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flipping Forms</title>
		<link>http://www.wildphp.com/basics/flipping-forms/</link>
		<comments>http://www.wildphp.com/basics/flipping-forms/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 04:31:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=172</guid>
		<description><![CDATA[For this series of tutorials I said you needed to know HTML. Since I am a nice guy I will teach you the limited HTML we need to know for our next two tutorials. Let&#8217;s start with a basic HTML document and then go from there.


&#60;html&#62;
&#60;head&#62;
&#60;title&#62;Flipping Forms Tutorial&#60;/title&#62;
&#60;/head&#62;
&#60;body&#62;
The following is a form:
&#60;/body&#62;
&#60;/html&#62;

In previous tutorials we [...]]]></description>
			<content:encoded><![CDATA[<p>For this series of tutorials I said you needed to know HTML. Since I am a nice guy I will teach you the limited HTML we need to know for our next two tutorials. Let&#8217;s start with a basic HTML document and then go from there.</p>
<pre class="brush: html">

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Flipping Forms Tutorial&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
The following is a form:
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>In previous tutorials we have manually entered our integers and strings. For this we needed access to our PHP file to change the values. This would not be particularly helpful to a typical user on your website. HTML forms allow us to submit values to PHP which we can process. Let&#8217;s make a simple form</p>
<pre class="brush: html">

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Flipping Forms Tutorial&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
The following is a form:

&lt;form action=&quot;index.php&quot;&gt;
What is your favorite book?: &lt;input type=&quot;text&quot; name=&quot;book&quot; /&gt;
What is your favorite movie?: &lt;input type=&quot;text&quot; name=&quot;movie&quot; /&gt;
What is your favorite website?: &lt;input type=&quot;text&quot; name=&quot;website&quot; /&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Let&#8217;s go through the HTML one part at a time. If you are already well versed in HTML you should be able to skip this tutorial, and move on to the next one on POST.</p>
<p><strong>Action=&#8221;index.php&#8221;</strong> &#8211; This line is the document that you are directed to after you hit the submit button. I am assuming you are still using index.php to run your PHP code .If you are not, you will have to modify it to the one you are using. You can direct it to a completely different one to run your PHP code there as well (more in the next tutorial).</p>
<p><strong>&lt;input type=&#8221;text&#8221; name=&#8221;book&#8221; /&gt;</strong> &#8211; In this line we have the textbox type which is text for textbox. We also have a name which is very important. Follow the same rules as the PHP variable names to keep everything simple. We will use this name to access it in PHP so keep it simple and short.</p>
<p><strong>&lt;input type=&#8221;submit&#8221; /&gt;</strong> &#8211; Our submit button. You can also add value=&#8221;Your Text&#8221;, to change the text from &#8220;Submit Query&#8221;.</p>
<p>Now that you have a little more knowledge with PHP forms, we can move on to more fun things!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/flipping-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Challenge 3</title>
		<link>http://www.wildphp.com/basics/code-challenge-three/</link>
		<comments>http://www.wildphp.com/basics/code-challenge-three/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 03:36:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=170</guid>
		<description><![CDATA[Me again! I hope you are having fun with loops and arrays, so let’s test your knowledge.
Questions
Q: What is a loop?
Show Answer &#9660;

A loop allows for the repeating of portions of code over and over again.

Q: What is the syntax when using a For loop?
Show Answer &#9660;



&#60;?php
for ( counting var; conditional statement; increment var)
{
//code
}
?&#62;


Q: What [...]]]></description>
			<content:encoded><![CDATA[<p>Me again! I hope you are having fun with loops and arrays, so let’s test your knowledge.</p>
<h1>Questions</h1>
<p>Q: What is a loop?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID378347915'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID378347915' style='display:none;'>
<p>A loop allows for the repeating of portions of code over and over again.</p>
</div>
<p>Q: What is the syntax when using a For loop?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID185641041'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID185641041' style='display:none;'>
<pre class="brush: php">

&lt;?php
for ( counting var; conditional statement; increment var)
{
//code
}
?&gt;
</pre>
</div>
<p>Q: What is the syntax for a While loop?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1068625239'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1068625239' style='display:none;'>
<pre class="brush: php">

&lt;?php
while ( conditional statement)
{
//code
}
?&gt;
</pre>
</div>
<p>Q: What is an infinite loop?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID277436288'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID277436288' style='display:none;'>
<p>The loop condition is never met and the loop keeps repeating forever.</p>
</div>
<p>Q: What is an array index?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1822027930'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1822027930' style='display:none;'>
<p>A location in an array with an individual value.</p>
</div>
<h1>Programming Projects</h1>
<p>Project One: Write a program that prints out “I Love WildPHP.com!” 10 times. Use <strong>While</strong> and <strong>For</strong> loops.</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID993383391'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID993383391' style='display:none;'>
<pre class="brush: php">

&lt;?php
//For Loop
for($i=1; $i&lt;=5; $i++)
{
echo &quot;I Love WildPHP.com! &quot;;
}

//While Loop
$i=1;
while($i&lt;=5)
{
echo &quot;I Love WildPHP.com! &quot;;
$i++;
}
?&gt;
</pre>
</div>
<p>Project Two: Write a loop that will add all the numbers in the following integer array: 22, 56, 7, 32, and 11.</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1388673463'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1388673463' style='display:none;'>
<pre class="brush: php">

&lt;?php
//Declare Array
$numbers = array(22, 56, 7, 32, 11);

//Sum Variable
$sum = 0;

//For Loop
for($i=0; $i&lt;5; $i++)
{
$sum += $numbers[$i];
}

echo &quot;The sum is &quot;.$sum;
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>The sum is 128</p></blockquote>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/code-challenge-three/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Awesome Arrays</title>
		<link>http://www.wildphp.com/basics/awesome-arrays/</link>
		<comments>http://www.wildphp.com/basics/awesome-arrays/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 01:20:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=168</guid>
		<description><![CDATA[At the start of this series of tutorial we learned how to use variable. As you already know variable store information for use for editing and later use. So what happens when you need use a bunch of variable?  Let&#8217;s say for example you wanted to store a bunch of ice cream flavors, lets say [...]]]></description>
			<content:encoded><![CDATA[<p>At the start of this series of tutorial we learned how to use variable. As you already know variable store information for use for editing and later use. So what happens when you need use a bunch of variable?  Let&#8217;s say for example you wanted to store a bunch of ice cream flavors, lets say 8. Using what we learned up to this would take a few lines because we would need to create a new variable to store each new flavor. This is where <strong>arrays</strong> come in handy.</p>
<p>Arrays can store all types of values from string to integers to many different types we have yet to go over. Lets try out a simple array before we move on to our example:</p>
<pre class="brush: php">

&lt;?php
//One way to declare an array
$apartment = array(&quot;Ground Floor&quot;,&quot;Floor 1&quot;,&quot;Floor 2&quot;,&quot;Floor 3&quot;);

//Other way to declare an array
$apartment[0]=&quot;Ground Floor&quot;;
$apartment[1]=&quot;Floor 1&quot;;
$apartment[2]=&quot;Floor 2&quot;;
$apartment[3]=&quot;Floor 3&quot;;

//Print out a floor name
echo $apartment[2];
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>Floor 2</p></blockquote>
<p>Think of an array as a stack of variables. Instead of creating a bunch of variables, we can simply create an array. The individual values in an array, by it&#8217;s index. If your confused you can think of an array as a building with individual values on each floor. If we specify we want to go to index or &#8220;floor&#8221; 0, remember we always start from zero in PHP, we might find a stored value like &#8220;chocolate.&#8221; If we where to go to 6th index or &#8220;floor&#8221; we could find a value like vanilla.</p>
<pre class="brush: php">

&lt;?php
//Declare our array
$flavors = array(&quot;Chocolate &quot;, &quot;Strawberry &quot;, &quot;Butter pecan &quot;, &quot;Neapolitan &quot;,
&quot;Vanilla fudge ripple &quot;, &quot;French vanilla &quot;, &quot;Vanilla &quot;, &quot;Cookies and cream &quot;);

//Edit a flavor
$flavors[0] = &quot;Chocolate chip &quot;;

//Print our flavors
echo &quot;Our Flavors: &quot;;
for($i=0; $i&lt;=7; $i++)
{
echo $flavors[$i];
}
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>Our Flavors: Chocolate chip Strawberry Butter pecan Neapolitan Vanilla fudge ripple French vanilla Vanilla Cookies and cream</p></blockquote>
<p>Wwe can do the same thing more efficiently with arrays. We can easily add other ice cream flavor, and have it print out for us without adding additional lines.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/awesome-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wild While Loops</title>
		<link>http://www.wildphp.com/basics/wild-while-loops/</link>
		<comments>http://www.wildphp.com/basics/wild-while-loops/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 00:34:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=163</guid>
		<description><![CDATA[In the previous tutorial we covered loops. &#8220;While&#8221; loops are similar, but are best used in different situations. The concept is similar to what we learned earlier concerning if and switch statements, and how they can basically complete the same function, but each is better for certain tasks.
A while loop has a much simpler format [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous tutorial we covered loops. &#8220;While&#8221; loops are similar, but are best used in different situations. The concept is similar to what we learned earlier concerning if and switch statements, and how they can basically complete the same function, but each is better for certain tasks.</p>
<p>A <strong>while</strong> loop has a much simpler format than the<strong> for</strong> loop.Thinking back to the previous tutorial, the second argument in the for statement was a condition. In a while loop this is the only thing we need. Let&#8217;s use the example from the previous tutorial and repeat it in a while loop.</p>
<pre class="brush: php">

&lt;?php
//First Declare the Counter Variable
$i=1;
//Same Conditional Statement as the For Loop
while($i &lt;= 5)
{
echo &quot;This is a test. &quot;;
//Increment must be in the loop or
//we will have an infinite loop
$i++;
}
?&gt;
</pre>
<p>The comments above should provide some guidance regarding how the while loops are similar to for loops. We cannot declare the counter variable inside the statement, we must declare it before. Also, we must make sure to make the counter variable change inside the loop or it will just go on forever.</p>
<p>It’s best to use while loops when you want the loop to be dynamic rather than static. For our for loop example we counted down from 10 to 0. We knew that we needed to count down from 10 to 0, so it was quite easy to use a for statement to do this. You would use a while if you really did not know.</p>
<p>For example, if you wanted to count from two random numbers, in this case 6 to 17, your code would look something like this:</p>
<pre class="brush: php">

&lt;?php
$start = 6;
$end = 17;

echo &quot;We are counting from &quot;.$start.&quot; to &quot;.$end.&quot;. &quot;;

while($start &lt;= $end)
{
echo $start.&quot;... &quot;;
$start++;
}

echo &quot; All Done!&quot;;
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>We are counting from 6 to 17. 6&#8230; 7&#8230; 8&#8230; 9&#8230; 10&#8230; 11&#8230; 12&#8230; 13&#8230; 14&#8230; 15&#8230; 16&#8230; 17&#8230;  All Done!</p></blockquote>
<p>It is up to you to decide if you want to used Wild While Loops or Flash For Loops.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/wild-while-loops/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flashy For Loops</title>
		<link>http://www.wildphp.com/basics/flashy-for-loops/</link>
		<comments>http://www.wildphp.com/basics/flashy-for-loops/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 15:50:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=150</guid>
		<description><![CDATA[Sometimes, once is just not enough. Thankfully, in PHP we have something called loops to help us. Basically, they allow us to repeat portions of code over and over again as much as we would like. For this tutorial let&#8217;s use two examples. Let&#8217;s say you want to first print out a simple statement five [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, once is just not enough. Thankfully, in PHP we have something called loops to help us. Basically, they allow us to repeat portions of code over and over again as much as we would like. For this tutorial let&#8217;s use two examples. Let&#8217;s say you want to first print out a simple statement five times. In regular PHP code, not using loops, it would look something like this:</p>
<pre class="brush: php">

&lt;?php
echo &quot;This is a test. &quot;;
echo &quot;This is a test. &quot;;
echo &quot;This is a test. &quot;;
echo &quot;This is a test. &quot;;
echo &quot;This is a test. &quot;;
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>This is a test. This is a test. This is a test. This is a test. This is a test.</p></blockquote>
<p>If we needed to print even more of this statement we would need to use even more lines of code. With a simple statement we can print out the same lines as many times as we want.</p>
<pre class="brush: php">

&lt;?php
for($i = 1; $i &lt;= 5; $i++)
{
echo &quot;This is a test. &quot;;
}
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>This is a test. This is a test. This is a test. This is a test. This is a test.</p></blockquote>
<p>Just as like if statement you put the code you want to run in-between two brackets.  <strong>For ( counting variable; conditional statement; increment counting variable)</strong>. In this case $i is our variable. We do a conditional just like in an if statement. If the variable $i is less than or equal to 5, then the code in the brackets will keep running. If not it will move on past the for statement. The last one adds one to the variable every time to code is run in the loop. We can also subtract one like this $i&#8211;; If you where to do that in this statement it would cause an <strong>infinite loop</strong>! This is where the middle condition is never met and the loop keeps repeating. This is because the $i variable would go 0,-1,-2,-3, etc. and always be less than 5.</p>
<p>We can also easily use variables to make for statements do much more for us. See the following example:</p>
<pre class="brush: php">

&lt;?php
echo &quot;Countdown!&quot;;

for($i = 10; $i &gt;= 0; $i--)
{
echo $i.&quot;...&quot;;
}

echo &quot;Blast Off!&quot;;
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>Countdown!10&#8230; 9&#8230; 8&#8230; 7&#8230; 6&#8230; 5&#8230; 4&#8230; 3&#8230; 2&#8230; 1&#8230; 0&#8230; Blast Off!</p></blockquote>
<p>We can also print out the counter variable to produce unique results. See you in the next tutorial on while loops.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/flashy-for-loops/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Challenge 2</title>
		<link>http://www.wildphp.com/basics/code-challenge-two/</link>
		<comments>http://www.wildphp.com/basics/code-challenge-two/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 01:47:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=127</guid>
		<description><![CDATA[Up for another code challenge? Since the first code challenge we have covered string functions and conditions. Let&#8217;s see how much you know. Again, no cheating!
Questions
Q: Write a line of code combining two string variables, $var and $var2, into $var3.
Show Answer &#9660;



$var3 = $var.$var2;


Q: What is an escape character?
Show Answer &#9660;

Special syntax that allows us [...]]]></description>
			<content:encoded><![CDATA[<p>Up for another code challenge? Since the first code challenge we have covered string functions and conditions. Let&#8217;s see how much you know. Again, no cheating!</p>
<h1>Questions</h1>
<p>Q: Write a line of code combining two string variables, $var and $var2, into $var3.</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID774358013'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID774358013' style='display:none;'>
<pre class="brush: php">

$var3 = $var.$var2;
</pre>
</div>
<p>Q: What is an escape character?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1131615999'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1131615999' style='display:none;'>
<p>Special syntax that allows us to use some characters that don&#8217;t work regularly.</p>
</div>
<p>Q: List the 6 most important escape characters we discussed.</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1520377189'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1520377189' style='display:none;'>
<ul>
<li>Newline – \n</li>
<li>Tab – \t</li>
<li>Single Quote – \’</li>
<li>Double Quote – \”</li>
<li>Dollar Sign – \$</li>
<li>Backslash – \\</li>
</ul>
</div>
<p>Q: Write a line of code that prints the length of this string literal, “How many cookies can I eat?”</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1438814362'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1438814362' style='display:none;'>
<pre class="brush: php">

echo strlen(&quot;How many cookies can I eat?&quot;);
</pre>
</div>
<p>Q: What does an else statement do?&#8221;</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID832756313'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID832756313' style='display:none;'>
<p>Runs if none of the if or elseif statements are true.</p>
</div>
<p>Q: What are 3 differences between if and switch statements?&#8221;</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1619543270'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1619543270' style='display:none;'>
<ol>
<li>Switch does not use brackets for each test</li>
<li>If statements don&#8217;t use break;</li>
<li>If statements use else and switch uses default</li>
</ol>
</div>
<h1>Programming Projects</h1>
<p>Project One: Write a program that reverses a string if it is more than 10 characters long.</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID867355640'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID867355640' style='display:none;'>
<pre class="brush: php">

&lt;?php
//Test String
$string = &quot;this is a test string&quot;;

//If Statement
if(strlen($string) &gt;10)    {
$string = strrev($string);
}

//Print it
echo $string;
?&gt;
</pre>
</div>
<p>Project Two: Write a program that checks if a string is a <a href="http://en.wikipedia.org/wiki/Palindrome">palindrome</a>.</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1114946233'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1114946233' style='display:none;'>
<pre class="brush: php">

&lt;?php
//Start string
$string = &quot;Able was I ere I saw Elba&quot;;
//Start string reversed
$string2 = strrev($string);

//Lowercase just to make sure
$string = strtolower($string);
$string2 = strtolower($string2);

//Remove spaces
$string = str_replace(&quot; &quot;, &quot;&quot;, $string);
$string2 = str_replace(&quot; &quot;, &quot;&quot;, $string2);

//If Statement
if($string == $string2)    {
echo &quot;It is a palindrome!&quot;;
}
else {
echo &quot;It is not a palindrome!&quot;;
}
?&gt;
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/code-challenge-two/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
