<?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>Quinterox &#187; PHP</title>
	<atom:link href="http://www.quinterox.com/content/category/code/php-learn/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.quinterox.com/content</link>
	<description>Cesar Quinteros</description>
	<lastBuildDate>Sun, 20 Jun 2010 04:51:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Enable And Disable Directory Browsing</title>
		<link>http://www.quinterox.com/content/code/enable-and-disable-directory-browsing/</link>
		<comments>http://www.quinterox.com/content/code/enable-and-disable-directory-browsing/#comments</comments>
		<pubDate>Sat, 25 Jul 2009 07:32:15 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[add index]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[remove index]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=680</guid>
		<description><![CDATA[Adding and removing Linux server file indexes.]]></description>
			<content:encoded><![CDATA[<p>When setting up the structure to my website that includes private and public files I often found a need for a way for certain folders NOT to display a list of its containing files. After searching the web I found it well as a nice link with some .htaccess know how.</p>
<h3>Removing Indexes</h3>
<pre>
Options -Indexes
</pre>
<p></p>
<h3>Adding Indexes</h3>
<pre>
Options +Indexes
</pre>
<p>
As simple as that! Here is the link I found that might come in pretty handy.<br />
<a href="http://www.hostingmanual.net/other/htfun.shtml">http://www.hostingmanual.net/other/htfun.shtml</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/enable-and-disable-directory-browsing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Expire Headers to Htaccess File</title>
		<link>http://www.quinterox.com/content/code/adding-expire-headers-to-htaccess-file/</link>
		<comments>http://www.quinterox.com/content/code/adding-expire-headers-to-htaccess-file/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 04:29:48 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[expire headers]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=654</guid>
		<description><![CDATA[How to add expire headers to your .htaccess file in order to save you from unnecessary server requests.]]></description>
			<content:encoded><![CDATA[<p>Adding expire headers is a good way to keep client requests to a minimum. Without them every time the client&#8217;s browser requests a file the server has to serve it. Adding expire headers, in this case to the .htaccess file, keeps a cached version of the requested file on the client&#8217;s computer in case it is requested again. For example, you have an image gallery. The client clicks on a picture, the picture is served to them, fine. Now when the client clicks the link at the top of your page to return to the main gallery page, ALL those thumbnails of the large images are requested from the server. With this code the client merely retrieves the same images he originally saw again, without the extra server requests. Nice isn&#8217;t it?<br />
<code><br />
&lt;FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$"&gt;<br />
Header unset Last-Modified<br />
Header set Expires "Fri, 10 Jun 2050 00:00:00 GMT"<br />
Header set Cache-Control "public, no-transform"<br />
&lt;/FilesMatch&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/adding-expire-headers-to-htaccess-file/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Turning on Gzip Compression</title>
		<link>http://www.quinterox.com/content/code/turning-on-gzip-compression/</link>
		<comments>http://www.quinterox.com/content/code/turning-on-gzip-compression/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 04:14:47 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=650</guid>
		<description><![CDATA[How to Gzip through the .htaccess file.]]></description>
			<content:encoded><![CDATA[<p>Gzipping files could be very useful when trying to speed up your website.</p>
<p>Though I do not have the whole .htaccess thing down yet. I have found some code that simply works. As always I post it for myself as well as anyone who needs it.</p>
<p><code><br />
&lt;IfModule mod_deflate.c&gt;<br />
&lt;FilesMatch "\.(js|css)$"&gt;<br />
SetOutputFilter DEFLATE<br />
&lt;/FilesMatch&gt;<br />
&lt;/IfModule&gt;<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/turning-on-gzip-compression/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Connecting to a MySQL database</title>
		<link>http://www.quinterox.com/content/code/connecting-to-a-mysql-database/</link>
		<comments>http://www.quinterox.com/content/code/connecting-to-a-mysql-database/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 04:59:19 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[connecting]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=477</guid>
		<description><![CDATA[Simple steps to connect to and extract data from a MySQL database.]]></description>
			<content:encoded><![CDATA[<p>Below are the steps to connect to and extract data from a MySQL database.</p>
<h3>Connecting to the database</h3>
<p>Step 1. Create and configure some connection variables.</p>
<pre>
$mysql_server = "mysql.yourserver.com";
$mysql_user = "admin";
$mysql_pwd= "password";
$mysql_db= "mydatabase";
</pre>
<p><br class="clear" /><br />
Step 2. Create connection.</p>
<pre>
$mysql_connection =
mysql_connect($mysql_server, $mysql_user, $mysql_pwd);
</pre>
<p><br class="clear" /><br />
Step 3. Select your database.</p>
<pre>
mysql_select_db($mysql_db) or die("Unable to select a database.");
</pre>
<p><br class="clear" /><br />
Step 4. Create your SQL string.</p>
<pre>
$mysql_sql = "SELECT * FROM mytable";
</pre>
<p><br class="clear" /><br />
Step 5. Combine your connection string and your SQL to return data.</p>
<pre>
$mysql_result = mysql_query($mysql_sql, $mysql_connection);
</pre>
<p><br class="clear" /></p>
<h3>Printing the data</h3>
<p>Step 6. Loop through the results and write it to the page. This output&#8217;s format is not pretty since it is meant to be simple.</p>
<pre>
while($data_row = mysql_fetch_row($mysql_result)) {
    foreach($data_row as $data_field) {
        print $data_field;
    }
    print "&lt;br /&gt;";
}
</pre>
<p><br class="clear" /><br />
Step 7. Close the connection string.</p>
<pre>
mysql_close($mysql_connection);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/connecting-to-a-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding expire tags to your CSS and JavaScript files</title>
		<link>http://www.quinterox.com/content/blog/expire-tags-adding-them-to-your-css-javascript/</link>
		<comments>http://www.quinterox.com/content/blog/expire-tags-adding-them-to-your-css-javascript/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 08:02:33 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[set expire]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=451</guid>
		<description><![CDATA[Adding expiration headers to PHP/ASP files.]]></description>
			<content:encoded><![CDATA[<p>Though we live in an age where a lot of people have fast internet connections. The focus (at least for developers) has shifted to technologies that relieve the server of heavy workloads and increase processing speeds such as AJAX, using server-side and client-side caching, as well as gzipping. In this post I will lightly touch upon client-side caching of dynamically generated CSS and JavaScript files.</p>
<p>I recently installed YSlow, a handy web development tool for Firefox. In it there is an option that tells you whether your CSS or JavaScript files are cached on the client&#8217;s computer allowing for a quicker page load. I noticed my files were not cached so I looked a little into how to go about caching them so the browser won&#8217;t download the same file over and over when going from page to page. So I went about conducting my own tests to see how to make this happen. The only way of making it happen other than setting an expire date/time on the WHOLE page (or on the .htaccess file in Linux servers) was to create a server-side file that would output the expiration, content type headers as well as the actual styles/code in your web application. Below is a clearer picture of how I made it happen.</p>
<h3>PHP- Step 1.</h3>
<p>Make a dynamically generated CSS file that includes expiration and content headers (code below). Save it as &#8216;dynamic_css.php&#8217;. The actual CSS styling can be typed in the same way you would do in a regular stylesheet, we are only after getting those expiration and content type headers sent out.</p>
<pre>&lt;?php
header("Expires: Thu, 31 Dec 2020 20:00:00 GMT");
header('Content-type: text/css');
?&gt;
h1 { color: Red; }</pre>
<p><br class="clear" /></p>
<h3>PHP- Step 2.</h3>
<p>Add &#8216;dynamic_css.php&#8217; as the CSS href of you document. This should make YSlow happy and increase the speed at which the user navigates through pages that use the same CSS file. Use the same method to add expiration tags to JavaScript.</p>
<pre>&lt;link rel="stylesheet" type="text/css" <strong><span style="color: #ff0000;">href="dynamic_css.php"</span></strong>/&gt;</pre>
<p><br class="clear" /></p>
<h3>ASP- Step 1.</h3>
<p>The way I added expire tags to my CSS code in ASP is very similar to PHP&#8217;s. First you make a server-side CSS file and save it as &#8216;dynamic_css.aspx&#8217;. Since it is important the headers hit the server first we use server-side code  to send those out first. We type in the actual CSS code like we would in a regular CSS file after that. Besides would you really want to Response.Write() all of your CSS code? I think not.</p>
<pre>&lt;%
    Response.Expires = 3600
    Response.ContentType = "text/css"
%&gt;
    h1 { color: Blue; }</pre>
<p><br class="clear" /></p>
<h3>ASP- Step 2.</h3>
<p>Add &#8216;dynamic_css.aspx&#8217; as the CSS source of you document. This should make YSlow happy since the expiration headers are now being sent increasing the speed at which the user navigates through the pages that share the same CSS file. Use this same header method to add expiration tags to JavaScript files.</p>
<pre>&lt;link rel="stylesheet" type="text/css" <strong><span style="color: #ff0000;">href="dynamic_css.aspx"</span></strong>/&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/blog/expire-tags-adding-them-to-your-css-javascript/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>ETag Removal</title>
		<link>http://www.quinterox.com/content/code/etag-removal/</link>
		<comments>http://www.quinterox.com/content/code/etag-removal/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 05:24:29 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ETag]]></category>
		<category><![CDATA[Remove]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=429</guid>
		<description><![CDATA[Simple ETag removal.]]></description>
			<content:encoded><![CDATA[<p>The main purpose of ETags is for servers to validate whether there is a new version of the file they are requesting. The problem is that sites served on multiple servers are likely to have ETags that do not match. This problem exists for both IIS and Apache served sites. This mismatch is not important in a small site served by a single server. However it is suggested that ETags be removed on larger websites with multiple servers, this decreases header data and thus allows for a faster load. Leaving the mismatching ETag however is said to bog down busier sites. Below is a simple piece of code that shows you how to remove ETags, just add it to your .htaccess file.</p>
<pre>FileETag None</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/etag-removal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamically Getting File and Website Address</title>
		<link>http://www.quinterox.com/content/code/dynamically-getting-file-and-website-address/</link>
		<comments>http://www.quinterox.com/content/code/dynamically-getting-file-and-website-address/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 06:49:07 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[dynamic file address]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=393</guid>
		<description><![CDATA[Getting the current web site's address or the current file location is simple in PHP. Here are a few examples.]]></description>
			<content:encoded><![CDATA[<p>Getting the current web site&#8217;s address is pretty simple and straight forward in PHP, no crazy functions nor regular expressions are needed. Below I demonstrate how to achieve this one line of code. Also I shall show you how to retrieve the page&#8217;s path from the root.</p>
<p>1. Get the current website address.</p>
<pre>$website = $_SERVER['HTTP_HOST'];</pre>
<p>Woah that was simple! Now the current folder path.</p>
<p>2. Get the current folder path.</p>
<pre>$filePath= $_SERVER['REQUEST_URI'];</pre>
<p>Did you catch that? It was so fast.</p>
<p>Put the first part and the second together (and of course add an &#8220;http://&#8221;) and you have the current file&#8217;s complete url!</p>
<pre>$fileWebAddress= "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/dynamically-getting-file-and-website-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Where to place your code</title>
		<link>http://www.quinterox.com/content/code/php-where-to-place-your-code/</link>
		<comments>http://www.quinterox.com/content/code/php-where-to-place-your-code/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 06:11:15 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[script tag]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=394</guid>
		<description><![CDATA[There are a few places where to place your PHP code on your dynamic web page. This all depends on your needs and preference. Of course there is a slight difference to whether you put it on a script tag, before any HTML, within your HTML, or at the bottom of the page. Here I will explain what I have found some of the differences to be.]]></description>
			<content:encoded><![CDATA[<p>There are a few places where to place your PHP code on your dynamic web page. This all depends on your needs and preference. Of course there is a slight difference to whether you put it on a script tag, before any HTML, within your HTML, or at the bottom of the page. Here I will explain what I have found some of the differences to be.</p>
<h3>Before HTML</h3>
<p>A few of the reasons you would want to place your code before the HTML are because you want to redirect the user to another page on your website, or getting data out of a database and placing it on your page as content.</p>
<pre><span style="color: #ff6600;"><span>&lt;?<span>php</span> $<span>pageTitle</span> = "Cesar's page"; ?&gt;</span></span>
<span>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.<span>dtd</span>"&gt;</span>
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
<span>&lt;meta http-equiv="Content-Type" content="text/html; <span>charset</span>=<span>utf</span>-8" /&gt;</span>
&lt;title&gt;<span style="color: #ff6600;"><strong><span>&lt;?<span>php</span> echo $<span>pageTitle</span>; ?&gt;</span></strong></span>&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt; ...</pre>
<p><br class="break" /></p>
<h3>In the script tag</h3>
<p>Yes! Just like Javascript you can place your PHP code within a script tag, but also like Javascript gets executed after your page loads. Though I have not seen many people using this method I think it really helps you keep your code clean and organized. It is similar to the .NET code placement.</p>
<pre><span>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.<span>dtd</span>"&gt;</span>
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
<span>&lt;meta http-equiv="Content-Type" content="text/html; <span>charset</span>=<span>utf</span>-8" /&gt;</span>
&lt;title&gt;My Web Page&lt;/title&gt;
<span style="color: #ff6600;"><strong><span>&lt;script language="<span>php</span>"&gt;</span>
$pageContent = "Cesar's page content.";
&lt;/script&gt;</strong>
</span>&lt;/head&gt;
&lt;body&gt;
<span>&lt;?<span>php</span> echo $<span>pageContent</span>; ?&gt;</span>
&lt;/body&gt;
&lt;/html&gt;</pre>
<p><br class="break" /></p>
<h3>Within HTML</h3>
<p>Mixing HTML and PHP is probably the most common way PHP applications are made. As useful and conventional as this type of coding can be, it can also become confusing. Below is an example of how that looks.</p>
<pre><span>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.<span>dtd</span>"&gt;</span>
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
<span>&lt;meta http-equiv="Content-Type" content="text/html; <span>charset</span>=<span>utf</span>-8" /&gt;</span>
&lt;title&gt;My Web Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<span style="color: #ff6600;"><strong><span>&lt;?<span>php</span></span>
<span>$<span>HeadDiv</span> = "&lt;div&gt;&lt;h1&gt;Welcome to my website!&lt;/h1&gt;&lt;/div&gt;";</span>
$BodyDiv = "&lt;div&gt;&lt;p&gt;Are you ready to hire me?! Click on my port...&lt;/p&gt;&lt;/div&gt;";
<span>$<span>FooterDiv</span> = "&lt;div&gt;copyright ...&lt;/div&gt;";</span>
?&gt;
<span>&lt;?<span>php</span></span>
<span>echo $<span>HeadDiv</span>;</span>
<span>echo $<span>BodyDiv</span>;</span>
<span>echo $<span>FooterDiv</span>;</span>
?&gt;</strong>
</span>&lt;/body&gt;
&lt;/html&gt;</pre>
<p><br class="break" /></p>
<h3>After HTML</h3>
<p>This might be an unorthodox way of code execution but nonetheless it is a possibility and depending on your application needs, it might be a useful one. Your code will execute after the HTML so anything that would be rendered above your HTML will render below it (afterwards) now. Here is how that looks. Please comment if you have an idea of how it would be useful.</p>
<pre><span>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.<span>dtd</span>"&gt;</span>
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
<span>&lt;meta http-equiv="Content-Type" content="text/html; <span>charset</span>=<span>utf</span>-8" /&gt;</span>
&lt;title&gt;My WebApp&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<span>&lt;form action="/code/untitled.<span>php</span>" method="post"&gt;</span>
&lt;input type="text" name="txtMessage" /&gt;
&lt;input type="submit" value="submit" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
<strong><span style="color: #ff6600;"><span>&lt;?<span>php</span> echo $_POST['txtMessage'];?&gt;</span></span></strong></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/php-where-to-place-your-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loops: break &amp; continue statements</title>
		<link>http://www.quinterox.com/content/code/loops-break-continue-statements/</link>
		<comments>http://www.quinterox.com/content/code/loops-break-continue-statements/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 18:05:45 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[break]]></category>
		<category><![CDATA[continue]]></category>
		<category><![CDATA[loops]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=19</guid>
		<description><![CDATA[Simple and easy to understand explanations of loop, break, and continue statements.]]></description>
			<content:encoded><![CDATA[<h3>Break</h3>
<p>Loops are very useful to help sift through information for what you need. However once you find your data you probably would like your loop to stop. For that you would have to use the BREAK statement.<br />
In this case the BREAK statement was used to not generate a division by zero warning. Watch as the code is stopped right before division by zero occurs.</p>
<pre>&lt;?php
$count = -10;
for (;$count &lt;= 10; $count++) {
     if ($count == 0) {
     break;
     } else {
             $result = 200/$count;
             echo "200 divided by $count is $result&lt;br /&gt;";
     }
}
?&gt;</pre>
<p><strong>Results: </strong><br />
200 divided by -10 is -20<br />
200 divided by -9 is -22.222222222222<br />
200 divided by -8 is -25<br />
200 divided by -7 is -28.571428571429<br />
200 divided by -6 is -33.333333333333<br />
200 divided by -5 is -40<br />
200 divided by -4 is  -50<br />
200 divided by -3 is -66.666666666667<br />
200 divided by -2 is -100<br />
200 divided by -1 is -200</p>
<h3>Continue</h3>
<p>The continue statement ends the execution of the current code lap but doesn&#8217;t stop the whole loop from continuing.</p>
<p>The following code, similar to the break, will stop the code from dividing by zero but continue afterwards.</p>
<pre>&lt;?php
$count = -10;
for (;$count &lt;= 10; $count++) {
     if ($count == 0) {
     continue;
     } else {
             $result = 200/$count;
             echo "200 divided by $count is $result&lt;br /&gt;";
     }
}
?&gt;</pre>
<p><strong>Results:</strong><br />
200 divided by -10 is -20<br />
200 divided by -9 is -22.222222222222<br />
200 divided by -8 is -25<br />
200 divided by -7 is -28.571428571429<br />
200 divided by -6 is -33.333333333333<br />
200 divided by -5 is -40<br />
200 divided by -4 is -50<br />
200 divided by -3 is -66.666666666667<br />
200 divided by -2 is -100<br />
200 divided by -1 is -200<br />
200 divided by 1 is 200<br />
200 divided by 2 is 100<br />
200 divided by 3 is 66.666666666667<br />
200 divided by 4 is 50<br />
200 divided by 5 is 40<br />
200 divided by 6 is 33.333333333333<br />
200 divided by 7 is 28.571428571429<br />
200 divided by 8 is 25<br />
200 divided by 9 is 22.222222222222<br />
200 divided by 10 is 20</p>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/loops-break-continue-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loops</title>
		<link>http://www.quinterox.com/content/code/php-learn/loops/</link>
		<comments>http://www.quinterox.com/content/code/php-learn/loops/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 02:49:46 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[loops]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=16</guid>
		<description><![CDATA[Examples of While, Do While, and For loops.]]></description>
			<content:encoded><![CDATA[<h3>While</h3>
<pre>&lt;?php
$count = 1;
while ($count &lt;= 12) {
        echo $count . "&lt;br /&gt;";
        $count++;
}
?&gt;</pre>
<p><br class="break" /></p>
<h3>Do while</h3>
<p>Similar to a while loop with the exception that the code block is executed before the loop repeats. Note how it does not keep executing after the code realizes $number is not greater than 100 and less than 200.</p>
<pre>&lt;?php
$number = 1;
do {
    echo $number . "&lt;br /&gt;";
    $number ++;
} while (($number &gt; 100) &amp;&amp; ($number &lt; 200));
?&gt;</pre>
<p><br class="break" /></p>
<h3>For (each)</h3>
<p>Like the While statement but without having to declare variables outside the loop. The For statement includes the variable which you are incrementing in one line of code.</p>
<pre>&lt;?php
for ($count = 1; $count &lt;= 12; $count++) {
     echo $count . "&lt;br /&gt;"
}
?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/php-learn/loops/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
