<?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>HTML-Tricks</title>
	<atom:link href="http://html-tricks.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://html-tricks.com</link>
	<description>Learn about HTML, CSS, JavaScript and PHP.</description>
	<lastBuildDate>Mon, 02 Aug 2010 00:40:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>PHP For Loop</title>
		<link>http://html-tricks.com/php/php-for-loop/</link>
		<comments>http://html-tricks.com/php/php-for-loop/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 00:33:09 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://html-tricks.com/?p=554</guid>
		<description><![CDATA[The &#8216;for&#8217; loop in PHP allows you to repeat certain code in an easy and intuitive manner. We&#8217;re going to cover the basics of it and also dig deeper into its full potential. Syntax for (counter; condition; counter modifier) { // Looping code goes here. } The counter is just a variable. The condition sets [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://html-tricks.com/wp-content/uploads/2010/07/forloop.png" alt="PHP For Loop" title="PHP For Loop" width="177" height="100" class="aligncenter size-full wp-image-563" /><br />
The &#8216;for&#8217; loop in PHP allows you to repeat certain code in an easy and intuitive manner. We&#8217;re going to cover the basics of it and also dig deeper into its full potential.<br />
<span id="more-554"></span> </p>
<h2>Syntax</h2>
<pre class="brush: php;">
for (counter; condition; counter modifier)
{
	// Looping code goes here.
}
</pre>
<p>The counter is just a variable. The condition sets how many times the code should execute. The counter modifier determines how the counter is modified each loop.</p>
<p>For example, if we wanted to output the numbers 1-10 with a linebreak in between each of them we&#8217;d do this:</p>
<pre class="brush: php;">
for ($i = 1; $i &lt; 11; $i++)
{
	echo $i . &quot;\n&quot;;
}
</pre>
<p>As you can see $i increments AFTER the code is executed. If it executed before the result would be 0-9.</p>
<h2>Further Examples</h2>
<p>Say we had an array, and we wanted to list off the values, separated by a new line. We would do the following:</p>
<pre class="brush: php;">
$array = array(&quot;foo&quot;, &quot;baz&quot;, &quot;foobar&quot;, &quot;foobaz&quot;);
$count = count($array);
for ($i = 0; $i &lt; $count; $i++)
{
	echo $array[$i], &quot;\n&quot;;
}
</pre>
<p>That would output:</p>
<p>foo<br />
baz<br />
foobar<br />
foobaz</p>
<p>However, you might think you&#8217;re clever and try doing this:</p>
<pre class="brush: php;">
$array = array(&quot;foo&quot;, &quot;baz&quot;, &quot;foobar&quot;, &quot;foobaz&quot;);
for ($i = 0; $i &lt; count($array); $i++)
{
	echo $array[$i], &quot;\n&quot;;
}
</pre>
<p>Though you save a line by doing this and it has the same output, you&#8217;re also counting the number of entries in $array each time it loops, which is bad for performance. Though you most likely wouldn&#8217;t notice it in such a small array, you definitely would if it has 100+ entrie; this is why you should count an array before hand when using the PHP for loop.</p>
<p>You&#8217;re also not limited to just incrementing the variable either, for example you could do this:</p>
<pre class="brush: php;">
for ($i = 0; $i &lt; 51; $i = $i + 10)
{
	echo $i . &quot;\n&quot;;
}
</pre>
<p>Which would output:</p>
<p>0<br />
10<br />
20<br />
30<br />
40<br />
50</p>
<p>The for loop can be very useful, but make sure you use it correctly. If you&#8217;re unsure of the efficiency of your code you can always try the <a href="http://php.net/manual/en/control-structures.while.php">while</a> loop.</p>
<h2>foreach Loop</h2>
<p>The foreach loop is very similar to the for loop but it&#8217;s meant specifically for arrays. We don&#8217;t recommend using it for large amounts of data since it tends to be slow.</p>
<p>Here&#8217;s the syntax:</p>
<pre class="brush: php;">
foreach ($array as $value)
{
	// Execute code here
}
</pre>
<p>So if we wanted to down our above array example with foreach we&#8217;d just do this:</p>
<pre class="brush: php;">
$array = array(&quot;foo&quot;, &quot;baz&quot;, &quot;foobar&quot;, &quot;foobaz&quot;);
foreach ($array as $value)
{
	echo $value, &quot;\n&quot;;
}
</pre>
<p>Again, we strongly recommend you do not use this where performance counts as it&#8217;s <a href="http://www.phpbench.com/">slower than the regular for loop</a>.</p>
<p>We hope you beginners enjoyed this article!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://html-tricks.com/php/php-for-loop/&amp;title=PHP+For+Loop" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=PHP+For+Loop+-+http://bit.ly/dD0OE6&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://html-tricks.com/php/php-for-loop/&amp;title=PHP+For+Loop" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://html-tricks.com/php/php-for-loop/&amp;title=PHP+For+Loop" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://html-tricks.com/php/php-for-loop/&amp;title=PHP+For+Loop" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://html-tricks.com/php/php-for-loop/&amp;t=PHP+For+Loop" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml-tricks.com%2Fphp%2Fphp-for-loop%2F&amp;t=PHP+For+Loop" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://html-tricks.com/php/php-for-loop/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://html-tricks.com/php/php-for-loop/&amp;title=PHP+For+Loop" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://html-tricks.com/php/php-for-loop/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://html-tricks.com/php/php-for-loop/&amp;h=PHP+For+Loop" rel="nofollow" class="external" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://html-tricks.com/php/php-for-loop/&amp;t=PHP+For+Loop" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://html-tricks.com/php/php-for-loop/&amp;title=PHP+For+Loop&amp;description=%0D%0AThe%20%27for%27%20loop%20in%20PHP%20allows%20you%20to%20repeat%20certain%20code%20in%20an%20easy%20and%20intuitive%20manner.%20We%27re%20going%20to%20cover%20the%20basics%20of%20it%20and%20also%20dig%20deeper%20into%20its%20full%20potential.%0D%0A%20%0D%0ASyntax%0D%0A%5Bphp%5D%0D%0Afor%20%28counter%3B%20condition%3B%20counter%20modifier%29%0D%0A%7B%0D%0A%09%2F%2F%20Looping%20code%20goes%20here.%0D%0A%7D%0D%0A%5B%2Fphp%5D%0D%0A%0D%0AThe%20counter%20is%20jus" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://html-tricks.com/php/php-for-loop/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Meta Tag: Facts and Myths</title>
		<link>http://html-tricks.com/html/meta-tag/</link>
		<comments>http://html-tricks.com/html/meta-tag/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 23:13:32 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://html-tricks.com/?p=520</guid>
		<description><![CDATA[The HTML meta tag is surrounded with confusion. It serves many purposes and most people don&#8217;t understand its many uses. Many people spam keywords in their meta tags to increase their SEO, whilst others use it for site redirects; are these methods effective? We&#8217;re going to uncover the truth about meta tags. Do meta keywords [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://html-tricks.com/wp-content/uploads/2010/07/metatag.png" alt="" title="The Meta Tag" width="256" height="256" class="aligncenter size-full wp-image-523" /><br />
The HTML meta tag is surrounded with confusion. It serves many purposes and most people don&#8217;t understand its many uses. Many people spam keywords in their meta tags to increase their SEO, whilst others use it for site redirects; are these methods effective? We&#8217;re going to uncover the truth about meta tags.<br />
<span id="more-520"></span></p>
<h2>Do meta keywords &#038; description improve search engine rank?</h2>
<p>The short answer: no they do not. Meta keywords are generally not worth your time to add. However the meta description is often used by Google to display the site page&#8217;s description instead of it automatically generating something based off the page&#8217;s content. This does not however make your web page rank any higher. In case you don&#8217;t know how to make a meta description you just do the following:
<pre class="brush: xml; light: true;">&lt;meta name=&quot;description&quot; content=&quot;You put your site's description here.&quot; /&gt;</pre>
<h2>Is using meta redirects a good idea?</h2>
<p>Yes and no, depending on the circumstances. If your site has moved and you want to redirect people to your new site I would not advise you to use it unless you don&#8217;t have access to a server side language such as PHP. Google automatically ignores pages that are redirects and does not follow where the page redirects to. It&#8217;d be a much better choice to send a redirection header, which Google does follow. You can do so in PHP like this:</p>
<pre class="brush: php; light: true;">header('Location: http://newsite.example.com');</pre>
<p>If you would like to know how to make meta redirects and don&#8217;t know already you can use the following HTML snippet:</p>
<pre class="brush: xml; light: true;">&lt;meta http-equiv=&quot;Refresh&quot; content=&quot;10;url=http://www.example.com&quot; /&gt;</pre>
<p> You can replace &#8220;10&#8243; with the number of seconds you&#8217;d like the page to wait before redirecting.<br />
In conclusion, avoid meta redirects if possible.</p>
<h2>Is stopping bots from indexing certain pages OK to do with meta tags?</h2>
<p>It is OK, but you have to realize a couple things:<br />
1) Only the &#8216;friendly&#8217; bots (such as Google, Yahoo and MSN) will not index the page.<br />
2) Using <em>robots.txt</em> is much easier to do than individually adding a meta tag to each page you don&#8217;t want search engines to index.</p>
<p>For those who don&#8217;t know how to use meta tags to stop search engines from indexing a page you add this to the <head> section:</p>
<pre class="brush: xml; light: true;">&lt;meta name=&quot;robots&quot; content=&quot;NOINDEX&quot; /&gt;</pre>
<h2>What are some other uses of the meta tag?</h2>
<p>The meta tag has many other uses in addition to the ones mentioned above. For example you can add copyrights like this:</p>
<pre class="brush: xml; light: true;">&lt;meta name=&quot;copyright&quot; CONTENT=&quot;&amp;copy; 2010 My Company&quot;&gt;</pre>
<p>You can also declare character sets which will let your site validate (assuming there are no other errors) like this:</p>
<pre class="brush: xml; light: true;">&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;</pre>
<p>If you want ONLY Google not to index your page you can do this:</p>
<pre class="brush: xml; light: true;">&lt;meta name=&quot;GOOGLEBOT&quot; content=&quot;NOARCHIVE&quot; /&gt;</pre>
<p>We hope this article helped you out, leave a comment if you wish, telling us of any additional meta tag knowledge you&#8217;d like to add.</p>
<p><strong>Resources</strong></p>
<ul>
<li><a href="http://vancouver-webpages.com/META/mk-metas.html">Meta Tag Builder</a></li>
<li><a href="http://www.i18nguy.com/markup/metatags.html">List of Meta Tags</a></li>
</ul>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://html-tricks.com/html/meta-tag/&amp;title=The+Meta+Tag%3A+Facts+and+Myths" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=The+Meta+Tag%3A+Facts+and+Myths+-+http://bit.ly/dnKs4L&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://html-tricks.com/html/meta-tag/&amp;title=The+Meta+Tag%3A+Facts+and+Myths" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://html-tricks.com/html/meta-tag/&amp;title=The+Meta+Tag%3A+Facts+and+Myths" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://html-tricks.com/html/meta-tag/&amp;title=The+Meta+Tag%3A+Facts+and+Myths" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://html-tricks.com/html/meta-tag/&amp;t=The+Meta+Tag%3A+Facts+and+Myths" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml-tricks.com%2Fhtml%2Fmeta-tag%2F&amp;t=The+Meta+Tag%3A+Facts+and+Myths" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://html-tricks.com/html/meta-tag/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://html-tricks.com/html/meta-tag/&amp;title=The+Meta+Tag%3A+Facts+and+Myths" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://html-tricks.com/html/meta-tag/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://html-tricks.com/html/meta-tag/&amp;h=The+Meta+Tag%3A+Facts+and+Myths" rel="nofollow" class="external" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://html-tricks.com/html/meta-tag/&amp;t=The+Meta+Tag%3A+Facts+and+Myths" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://html-tricks.com/html/meta-tag/&amp;title=The+Meta+Tag%3A+Facts+and+Myths&amp;description=%0D%0AThe%20HTML%20meta%20tag%20is%20surrounded%20with%20confusion.%20It%20serves%20many%20purposes%20and%20most%20people%20don%27t%20understand%20its%20many%20uses.%20Many%20people%20spam%20keywords%20in%20their%20meta%20tags%20to%20increase%20their%20SEO%2C%20whilst%20others%20use%20it%20for%20site%20redirects%3B%20are%20these%20methods%20effective%3F%20We%27re%20going%20to%20uncover%20the%20truth%20about%20m" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://html-tricks.com/html/meta-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>5 Underused PHP Functions</title>
		<link>http://html-tricks.com/php/5-underused-functions/</link>
		<comments>http://html-tricks.com/php/5-underused-functions/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 21:13:43 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://html-tricks.com/?p=481</guid>
		<description><![CDATA[PHP, over the years, has evolved into a vast language with many useful functions that are overlooked. Here&#8217;s 5 functions that you have probably never used to help make your next web application easier to create. wordwrap() wordwrap() will, as the name suggests, wrap words. After a specified amount of characters you can separate words [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://html-tricks.com/wp-content/uploads/2010/07/functions.png" alt="" title="5 Underused Functions" width="256" height="256" class="aligncenter size-full wp-image-506" /><br />
PHP, over the years, has evolved into a vast language with many useful functions that are overlooked. Here&#8217;s 5 functions that you have probably never used to help make your next web application easier to create.<br />
<span id="more-481"></span></p>
<h2>wordwrap()</h2>
<p><a href="http://php.net/manual/en/function.wordwrap.php">wordwrap()</a> will, as the name suggests, wrap words. After a specified amount of characters you can separate words with characters you choose. Here&#8217;s the basic format:</p>
<pre class="brush: php; light: true;">wordwrap($string, $char, $separator);</pre>
<p><strong>Example:</strong></p>
<pre class="brush: php;">
$string = &quot;Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.&quot;;
echo wordwrap($string, 50, &quot;\n&quot;);
/* Outputs:
Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.
*/
</pre>
<h2>money_format()</h2>
<p><a href="http://php.net/manual/en/function.money-format.php">money_format()</a> is a useful function which will let you format a number to be displayed like money. The PHP manual shows the available formatting options.</p>
<p><strong>Example:</strong></p>
<pre class="brush: php;">
$amount = 9999.99;
setlocale(LC_MONETARY, 'en_US');
echo money_format(&quot;%n&quot;, $amount); // Outputs &quot;USD 9,999.99&quot;
</pre>
<div class="note">Note: money_format() does not work on Windows.</div>
<h2>similar_text()</h2>
<p><a href="http://www.php.net/manual/en/function.similar-text.php">similar_text()</a> allows you to figure out how similar two strings are. Here&#8217;s the way you call it:</p>
<pre class="brush: php; light: true;">similar_text($string1, $string2, $refvar);</pre>
<p>$refvar will be assigned to the percent similarity of the two strings. 100 being that they&#8217;re the same and 0 being that they&#8217;re nothing alike.</p>
<p><strong>Example:</strong></p>
<pre class="brush: php;">
similar_text(&quot;html&quot;, &quot;tricks&quot;, $ref);
echo $ref; // Outputs 20
similar_text(&quot;html&quot;, &quot;xml&quot;, $ref);
echo $ref; // Outputs 57.142857142857
similar_text(&quot;html&quot;, &quot;html&quot;, $ref);
echo $ref; // Outputs 100
</pre>
<h2>highlight_string()</h2>
<p><a href="http://www.php.net/manual/en/function.highlight-string.php">highlight_string()</a> provides syntax highlighting for PHP code. It&#8217;s very easy to use:</p>
<pre class="brush: php; light: true;">highlight_string($code);</pre>
<p><strong>Example:</strong></p>
<pre class="brush: php;">
$code = '&lt;?php
echo $x . &quot;hello, world!&quot;;
?&gt;';
highlight_string($code);
</pre>
<p>This example would output the following:<br />
<code><span style="color: #000000"><br /><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$x&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"hello,&nbsp;world!"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span><br />
</span><br />
</code></p>
<h2>metaphone()</h2>
<p>Last but not least, <a href="http://www.php.net/manual/en/function.metaphone.php">metaphone()</a> takes a string and returns an approximate pronunciation of it.</p>
<p><strong>Example:</strong></p>
<pre class="brush: php;">
echo metaphone('tricks'); // Outputs &quot;TRKS&quot;
echo metaphone('website'); // Outputs &quot;WBST&quot;
</pre>
<p>Are we missing any functions? Share any obscure but useful PHP functions that you know about in a comment below. We hope these helped you!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://html-tricks.com/php/5-underused-functions/&amp;title=5+Underused+PHP+Functions" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=5+Underused+PHP+Functions+-+http://bit.ly/9aZLi9&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://html-tricks.com/php/5-underused-functions/&amp;title=5+Underused+PHP+Functions" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://html-tricks.com/php/5-underused-functions/&amp;title=5+Underused+PHP+Functions" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://html-tricks.com/php/5-underused-functions/&amp;title=5+Underused+PHP+Functions" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://html-tricks.com/php/5-underused-functions/&amp;t=5+Underused+PHP+Functions" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml-tricks.com%2Fphp%2F5-underused-functions%2F&amp;t=5+Underused+PHP+Functions" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://html-tricks.com/php/5-underused-functions/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://html-tricks.com/php/5-underused-functions/&amp;title=5+Underused+PHP+Functions" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://html-tricks.com/php/5-underused-functions/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://html-tricks.com/php/5-underused-functions/&amp;h=5+Underused+PHP+Functions" rel="nofollow" class="external" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://html-tricks.com/php/5-underused-functions/&amp;t=5+Underused+PHP+Functions" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://html-tricks.com/php/5-underused-functions/&amp;title=5+Underused+PHP+Functions&amp;description=%0D%0APHP%2C%20over%20the%20years%2C%20has%20evolved%20into%20a%20vast%20language%20with%20many%20useful%20functions%20that%20are%20overlooked.%20Here%27s%205%20functions%20that%20you%20have%20probably%20never%20used%20to%20help%20make%20your%20next%20web%20application%20easier%20to%20create.%0D%0A%0D%0Awordwrap%28%29%0D%0Awordwrap%28%29%20will%2C%20as%20the%20name%20suggests%2C%20wrap%20words.%20After%20a%20specified%20am" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://html-tricks.com/php/5-underused-functions/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Creating a Secure Hash in PHP</title>
		<link>http://html-tricks.com/php/creating-a-secure-hash-in-php/</link>
		<comments>http://html-tricks.com/php/creating-a-secure-hash-in-php/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 14:00:16 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://html-tricks.com/?p=422</guid>
		<description><![CDATA[When creating a web application with users it is always important to securely hash their password. We are going to go over how to create a hash that is impossible to brute force. We&#8217;ll assume that this script is open to the public and anyone can see the algorithm we use &#8211; so how do [...]]]></description>
			<content:encoded><![CDATA[<p>When creating a web application with users it is always important to securely hash their password. We are going to go over how to create a hash that is impossible to brute force.</p>
<p>We&#8217;ll assume that this script is open to the public and anyone can see the algorithm we use &#8211; so how do we make it uncrackable and non-bruteforcable?</p>
<p><span id="more-422"></span><br />
The answer is randomly generated <a href="http://en.wikipedia.org/wiki/Salting_%28cryptography%29">salts</a>. We&#8217;ll randomly generate a salt, store it in a database along with the username, hashed password and any other user associated information, and then generate their hashed password based off of the salt and password.</p>
<p>When we check  to see if they have a valid username/password we will check the database for the username the user supplied (via cookies or when logging in), pull out the password salt, hash the password that they have given with the salt and see if it fits the hash in the database.</p>
<h2>The Code</h2>
<p>First we&#8217;ll need to create a database (we&#8217;ll be using MySQL) and create a table within it. We&#8217;ll call the database &#8220;app&#8221; and the table &#8220;users&#8221;. For our intents and purposes we will only have three fields: the user ID, the username, and the hashed password. The user ID field will be auto incrementing. To create the table we will execute the following SQL:</p>
<pre class="brush: sql;">
CREATE TABLE `app`.`users` (
`uid` INT NOT NULL AUTO_INCREMENT ,
`username` TEXT NOT NULL ,
`hash` TEXT NOT NULL ,
`salt` TEXT NOT NULL ,
PRIMARY KEY ( `uid` )
)
</pre>
<p>Now we&#8217;re going to create a function which will register the user, first hashing the inputted password. We&#8217;re going to use the <a href="http://www.php.net/manual/en/function.uniqid.php">uniqid()</a> function to generate the salt. To create the hash based off the salt we&#8217;ll use <a href="http://www.php.net/manual/en/function.crypt.php">crypt()</a>. Here&#8217;s the code:</p>
<pre class="brush: php;">
function register($user, $password)
{
    $salt = uniqid(mt_rand()); // Create a salt based off the time, prefixed with a random number.
    $hash = crypt($password, $salt); // Generate the hash.
}
</pre>
<p>Next in the function we insert the data into our table.</p>
<pre class="brush: php;">
// We'll escape the input before this

$con = mysql_connect(&quot;localhost&quot;,&quot;peter&quot;,&quot;abc123&quot;); // Fill in database server, username and password
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}

mysql_select_db('app', $con);

mysql_query(&quot;INSERT INTO users (username, hash, salt)
VALUES ('$user', '$hash', '$salt')&quot;);

mysql_close($con);
</pre>
<p>All together now:</p>
<pre class="brush: php;">
function register($user, $password)
{
    $salt = uniqid(mt_rand()); // Create a salt based off the time, prefixed with a random number.
    $hash = crypt($password, $salt); // Generate the hash.
    // Prepare the data for the database
    $salt = mysql_real_escape_string($salt);
    $hash = mysql_real_escape_string($hash);
    $user2 = mysql_real_escape_string($user);
    $con = mysql_connect(&quot;localhost&quot;,&quot;peter&quot;,&quot;abc123&quot;);
    if (!$con)
    {
       die('Could not connect: ' . mysql_error());
    }
    mysql_select_db('app', $con);
    mysql_query(&quot;INSERT INTO users (username, hash, salt)
    VALUES ('$user2', '$hash', '$salt')&quot;);
    mysql_close($con);
}
</pre>
<p>Now we need a function which checks to see if the user supplied info (which would normally be stored in cookies or used during login) is valid. We&#8217;ll need to know their inputted username and password.</p>
<p>First we&#8217;ll connect to the database and find the salt and password hash given the username. To do this we&#8217;ll use the following SQL:</p>
<pre class="brush: sql;">
SELECT hash, salt
FROM users
WHERE username = '$username'
</pre>
<pre class="brush: php;">
function validateUser($username, $password)
{
    $user = mysql_real_escape_string($username);
    $con = mysql_connect(&quot;localhost&quot;,&quot;peter&quot;,&quot;abc123&quot;);
    if (!$con)
    {
       die('Could not connect: ' . mysql_error());
    }
    mysql_select_db('app', $con);
    $info = mysql_query(&quot;SELECT hash, salt FROM users WHERE username = '$user&quot;);
    $row = mysql_fetch_row($info);
    mysql_close($con);
}
</pre>
<p>Now that we&#8217;ve selected the proper row, the hash is stored in $row[0] and the salt is stored in $row[1]. For clarity&#8217;s sake we&#8217;ll assign them to $hash and $salt.</p>
<pre class="brush: php;">
$hash = $row[0];
$salt = $row[1];
</pre>
<p>Next we&#8217;ll hash the password using $salt and check to see if it matches $hash.</p>
<pre class="brush: php;">
$hashCheck = crypt($password, $salt);
if ($hashCheck == $hash)
{
    // The user provided a valid username and password.
}
</pre>
<p>And the final function:</p>
<pre class="brush: php;">
function validateUser($username, $password)
{
    $user = mysql_real_escape_string($username);
    $con = mysql_connect(&quot;localhost&quot;,&quot;peter&quot;,&quot;abc123&quot;);
    if (!$con)
    {
       die('Could not connect: ' . mysql_error());
    }
    mysql_select_db('app', $con);
    $info = mysql_query(&quot;SELECT hash, salt FROM users WHERE username = '$user'&quot;);
    $row = mysql_fetch_row($info);
    mysql_close($con);
    $hash = $row[0];
    $salt = $row[1];
    $hashCheck = crypt($password, $salt);
    if ($hashCheck == $hash)
    {
        // The user provided a valid username and password.
    }
}
</pre>
<p>There you have it! A secure way to create and verify password hashes in PHP, perfect for any user system. I hope you enjoyed this article and feel free to leave a comment!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://html-tricks.com/php/creating-a-secure-hash-in-php/&amp;title=Creating+a+Secure+Hash+in+PHP" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Creating+a+Secure+Hash+in+PHP+-+http://bit.ly/9ooKdT&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://html-tricks.com/php/creating-a-secure-hash-in-php/&amp;title=Creating+a+Secure+Hash+in+PHP" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://html-tricks.com/php/creating-a-secure-hash-in-php/&amp;title=Creating+a+Secure+Hash+in+PHP" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://html-tricks.com/php/creating-a-secure-hash-in-php/&amp;title=Creating+a+Secure+Hash+in+PHP" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://html-tricks.com/php/creating-a-secure-hash-in-php/&amp;t=Creating+a+Secure+Hash+in+PHP" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml-tricks.com%2Fphp%2Fcreating-a-secure-hash-in-php%2F&amp;t=Creating+a+Secure+Hash+in+PHP" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://html-tricks.com/php/creating-a-secure-hash-in-php/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://html-tricks.com/php/creating-a-secure-hash-in-php/&amp;title=Creating+a+Secure+Hash+in+PHP" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://html-tricks.com/php/creating-a-secure-hash-in-php/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://html-tricks.com/php/creating-a-secure-hash-in-php/&amp;h=Creating+a+Secure+Hash+in+PHP" rel="nofollow" class="external" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://html-tricks.com/php/creating-a-secure-hash-in-php/&amp;t=Creating+a+Secure+Hash+in+PHP" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://html-tricks.com/php/creating-a-secure-hash-in-php/&amp;title=Creating+a+Secure+Hash+in+PHP&amp;description=When%20creating%20a%20web%20application%20with%20users%20it%20is%20always%20important%20to%20securely%20hash%20their%20password.%20We%20are%20going%20to%20go%20over%20how%20to%20create%20a%20hash%20that%20is%20impossible%20to%20brute%20force.%0D%0A%0D%0AWe%27ll%20assume%20that%20this%20script%20is%20open%20to%20the%20public%20and%20anyone%20can%20see%20the%20algorithm%20we%20use%20-%20so%20how%20do%20we%20make%20it%20unc" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://html-tricks.com/php/creating-a-secure-hash-in-php/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>8 Site Features That You Should Avoid</title>
		<link>http://html-tricks.com/general/8-website-features/</link>
		<comments>http://html-tricks.com/general/8-website-features/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 20:40:26 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://html-tricks.com/?p=389</guid>
		<description><![CDATA[When creating websites some features sound like a great idea but in reality they only detract visitors. Even though the &#60;blink&#62; tag is gone (thank goodness!) there are many other equally annoying &#8220;features&#8221; that people often use, but shouldn&#8217;t. Here&#8217;s a list of these features you should avoid. 1. Marquees Marquees were nice back in [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://html-tricks.com/wp-content/uploads/2010/07/features.png" alt="" title="Features to Avoid" width="256" height="256" class="aligncenter size-full wp-image-418" /><br />
When creating websites some features sound like a great idea but in reality they only detract visitors. Even though the <code>&lt;blink&gt;</code> tag is gone (thank goodness!) there are many other equally annoying &#8220;features&#8221; that people often use, but shouldn&#8217;t. Here&#8217;s a list of these features you should avoid.<br />
<span id="more-389"></span></p>
<h2>1. Marquees</h2>
<p>Marquees were nice back in the 90s, but now they&#8217;re annoying and have been deprecated and removed as of HTML5. Readers don&#8217;t want to have to wait for the text to scroll so that they can read it all; they want the information now so that they can skip parts that they aren&#8217;t interested in.</p>
<h2>2. Background Music</h2>
<p>Background music is extremely annoying, especially if it automatically plays and/or you can&#8217;t stop it. No, we don&#8217;t all want to hear your favorite song. Trust us, your website will not gain traffic if you add background music.</p>
<h2>3. Tons of Fonts</h2>
<p>Having over 2-3 fonts on one page doesn&#8217;t look good. You want to focus on content and readability, not how many fonts you can stuff into one page.</p>
<h2>4. Text Links</h2>
<p><a href="http://www.kontera.com/">Text</a> <a href="http://www.infolinks.com/">links</a> are a very obnoxious way for you to monetize your sites. Visitors don&#8217;t want to accidentally bring up a dialog box whenever they accidentally hover over some word. Stick with traditional ads for your visitors sake.</p>
<h2>5. Ads with Sound</h2>
<p>Though it&#8217;s great that I just won a new iPod I don&#8217;t want to hear ads making noise. People go to your site for information, most people tolerate static ads but ads making noise is just too much, especially if your visitor is listening to music.</p>
<h2>6. Splash Pages</h2>
<p>Splash pages are simply irritating and they make one more step for the user to get to the content. No, they don&#8217;t make your website look professional.</p>
<h2>7. Popups</h2>
<p>Popups are terribly annoying, they shift the focus away from your site and if I see popups on a site it makes me want to leave.</p>
<h2>8. Frame based Designs</h2>
<p>Frames are terribly annoying when you&#8217;re trying to navigate through a website. Why? Because the back and forward buttons never work properly and if you try to open a link in a new tab you only open that frame, not the rest of the site.</p>
<p>We hope you don&#8217;t use any of these terrible elements of the web in the future. Are we missing something? Leave a comment telling us what features you think should be avoided.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://html-tricks.com/general/8-website-features/&amp;title=8+Site+Features+That+You+Should+Avoid" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=8+Site+Features+That+You+Should+Avoid+-+http://bit.ly/cGKlmd&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://html-tricks.com/general/8-website-features/&amp;title=8+Site+Features+That+You+Should+Avoid" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://html-tricks.com/general/8-website-features/&amp;title=8+Site+Features+That+You+Should+Avoid" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://html-tricks.com/general/8-website-features/&amp;title=8+Site+Features+That+You+Should+Avoid" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://html-tricks.com/general/8-website-features/&amp;t=8+Site+Features+That+You+Should+Avoid" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml-tricks.com%2Fgeneral%2F8-website-features%2F&amp;t=8+Site+Features+That+You+Should+Avoid" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://html-tricks.com/general/8-website-features/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://html-tricks.com/general/8-website-features/&amp;title=8+Site+Features+That+You+Should+Avoid" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://html-tricks.com/general/8-website-features/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://html-tricks.com/general/8-website-features/&amp;h=8+Site+Features+That+You+Should+Avoid" rel="nofollow" class="external" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://html-tricks.com/general/8-website-features/&amp;t=8+Site+Features+That+You+Should+Avoid" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://html-tricks.com/general/8-website-features/&amp;title=8+Site+Features+That+You+Should+Avoid&amp;description=%0D%0AWhen%20creating%20websites%20some%20features%20sound%20like%20a%20great%20idea%20but%20in%20reality%20they%20only%20detract%20visitors.%20Even%20though%20the%20%26lt%3Bblink%26gt%3B%20tag%20is%20gone%20%28thank%20goodness%21%29%20there%20are%20many%20other%20equally%20annoying%20%22features%22%20that%20people%20often%20use%2C%20but%20shouldn%27t.%20Here%27s%20a%20list%20of%20these%20features%20you%20should%20avoi" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://html-tricks.com/general/8-website-features/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building a Site File Structure Template</title>
		<link>http://html-tricks.com/general/file-structure/</link>
		<comments>http://html-tricks.com/general/file-structure/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 20:08:06 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://html-tricks.com/?p=343</guid>
		<description><![CDATA[When developing sites or projects, it helps to have an organized folder structure so that you can go back and find files easier, as well as have others easily understand how the website&#8217;s code works. We&#8217;ll also retain files in most of the commonly used folders so that every time you make a new site, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-345" title="Structure Template" src="http://html-tricks.com/wp-content/uploads/2010/06/sitestructure.png" alt="" width="256" height="256" /></p>
<p>When developing sites or projects, it helps to have an organized folder structure so that you can go back and find files easier, as well as have others easily understand how the website&#8217;s code works. We&#8217;ll also retain files in most of the commonly used folders so that every time you make a new site, you don&#8217;t have to rewrite practically identical code.<br />
<span id="more-343"></span></p>
<h2>Folders</h2>
<p>The first step is to figure out what folders we want to separate our code and media into. I find it best having a folder for CSS, a folder for JavaScript, and a folder for images.</p>
<p>Let&#8217;s start out with this:</p>
<ul>
<li><strong>css</strong></li>
<li><strong>js</strong></li>
<li><strong>images</strong></li>
</ul>
<p>This isn&#8217;t bad for a folder structure, but if your site uses images for the layout and images for other things such as a gallery, it is also nice to separate content further like so:</p>
<ul>
<li><strong>css</strong></li>
<li><strong>js</strong></li>
<li><strong>images</strong>
<ul>
<li><strong>layout</strong></li>
</ul>
</li>
</ul>
<p>If you work with PHP and like to separate your PHP code over several files, you might also want to add an includes folder..</p>
<h2>Files</h2>
<p>Now that you have your folder setup figured out, let&#8217;s move on to the files. We&#8217;ll go over what we should put (and not put) in each folder.</p>
<p><strong>css</strong><br />
Two files will go in the CSS folder, but you can always adjust this to your own needs. I always use a reset CSS stylesheet such as the <a href="http://developer.yahoo.com/yui/reset/">YUI Reset CSS</a> or <a href="http://meyerweb.com/eric/tools/css/reset/">Meyer Web&#8217;s reset</a>, as well as a <em>style.css</em>, where all the CSS code goes.</p>
<p>Additionally, you may also want to add stylesheets for other media such as a <em>print.css</em> file.</p>
<p>Now we have this:</p>
<ul>
<li><strong>css</strong>
<ul>
<li>style.css</li>
<li>reset.css</li>
</ul>
</li>
<li><strong>js</strong></li>
<li><strong>images</strong>
<ul>
<li><strong>layout</strong></li>
</ul>
</li>
</ul>
<p><strong>js</strong></p>
<p>What you put in the JavaScript folder really depends on what you use the most. You may wish to put a JavaScript framework in it such as <a href="http://jquery.com/">jQuery</a> or <a href="http://developer.yahoo.com/yui/">YUI</a>, or design enhancing scripts such as <a href="http://cufon.shoqolate.com/generate/">Cufon.js</a>, or even something you made yourself.</p>
<p><strong>images</strong><br />
The images folder will be left empty unless you tend to reuse certain graphics such as an AJAX spinner.</p>
<p><strong>The index file</strong></p>
<p>The index file (homepage) will vary based on what types of technologies you use and websites you make. For example, if you added jQuery to the JavaScript folder you&#8217;ll probably link to it in the index file.</p>
<p>The first thing to do is determine the ideal extension for the index file. If you work with PHP a lot make it <em>index.php</em>. If you just use static code you can name it <em>index.html</em>.</p>
<p>The next matter is to determine which doctype you&#8217;ll be using. You can find a list of doctypes <a href="http://www.w3schools.com/tags/tag_DOCTYPE.asp">here</a>. We will be using XHTML 1.0 Strict.</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt;Title&lt;/title&gt;
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;application/xhtml+xml; charset=UTF-8&quot; /&gt;
&lt;link href=&quot;./css/reset.css&quot; rel=&quot;stylesheet&quot; /&gt;
&lt;link href=&quot;./css/style.css&quot; rel=&quot;stylesheet&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Of course, yours will almost certainly vary a bit.</p>
<p>Here is the final folder architecture:</p>
<ul>
<li>index.php</li>
<li><strong>css</strong>
<ul>
<li>style.css</li>
<li>reset.css</li>
</ul>
</li>
<li><strong>js</strong></li>
<li><strong>images</strong>
<ul>
<li><strong>layout</strong></li>
</ul>
</li>
</ul>
<p>And there you have it! A good start for your next site&#8217;s file structure. Got an even better idea? Leave a comment.</p>
<div class="note">Specials thanks to <a href="http://veetri.com">Kyle Jenkins</a> for editing this post.</div>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://html-tricks.com/general/file-structure/&amp;title=Building+a+Site+File+Structure+Template" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Building+a+Site+File+Structure+Template+-+http://bit.ly/cg7Mtb&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://html-tricks.com/general/file-structure/&amp;title=Building+a+Site+File+Structure+Template" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://html-tricks.com/general/file-structure/&amp;title=Building+a+Site+File+Structure+Template" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://html-tricks.com/general/file-structure/&amp;title=Building+a+Site+File+Structure+Template" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://html-tricks.com/general/file-structure/&amp;t=Building+a+Site+File+Structure+Template" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml-tricks.com%2Fgeneral%2Ffile-structure%2F&amp;t=Building+a+Site+File+Structure+Template" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://html-tricks.com/general/file-structure/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://html-tricks.com/general/file-structure/&amp;title=Building+a+Site+File+Structure+Template" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://html-tricks.com/general/file-structure/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://html-tricks.com/general/file-structure/&amp;h=Building+a+Site+File+Structure+Template" rel="nofollow" class="external" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://html-tricks.com/general/file-structure/&amp;t=Building+a+Site+File+Structure+Template" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://html-tricks.com/general/file-structure/&amp;title=Building+a+Site+File+Structure+Template&amp;description=%0D%0A%0D%0AWhen%20developing%20sites%20or%20projects%2C%20it%20helps%20to%20have%20an%20organized%20folder%20structure%20so%20that%20you%20can%20go%20back%20and%20find%20files%20easier%2C%20as%20well%20as%20have%20others%20easily%20understand%20how%20the%20website%27s%20code%20works.%20We%27ll%20also%20retain%20files%20in%20most%20of%20the%20commonly%20used%20folders%20so%20that%20every%20time%20you%20make%20a%20new%20s" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://html-tricks.com/general/file-structure/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>5 Things Not to Do While Web Coding</title>
		<link>http://html-tricks.com/general/10-things-to-avoid/</link>
		<comments>http://html-tricks.com/general/10-things-to-avoid/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 17:28:23 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://html-tricks.com/?p=316</guid>
		<description><![CDATA[Creating websites is a complicated process and many coders can develop bad practices while creating them. Here&#8217;s 5 things not to do while web coding. Use a transitional doctype Using the HTML 4.01 &#8220;loose&#8221; doctype or the XHTML 1.0 Transitional doctype is a bad way to start a website. Instead, code with the strict doctype. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://html-tricks.com/wp-content/uploads/2010/06/5things.png" alt="" title="5 Things Not to Do" width="247" height="198" class="aligncenter size-full wp-image-326" /></p>
<p>Creating websites is a complicated process and many coders can develop bad practices while creating them. Here&#8217;s 5 things <em>not</em> to do while web coding.<br />
<span id="more-316"></span></p>
<h2>Use a transitional doctype</h2>
<p>Using the HTML 4.01 &#8220;loose&#8221; doctype or the XHTML 1.0 Transitional doctype is a bad way to start a website. Instead, code with the strict doctype. Some validation errors are silenced with the transitional doctypes and can cause problems later on.</p>
<h2>Write the CSS and HTML simultaneously</h2>
<p>When making a website, you should always fully write the HTML markup before even starting on the CSS. If you write them at the same time you can often lose your train of thought and it could take longer than it should to code the website.</p>
<h2>Use tables for the layout</h2>
<p>Tables were never meant to be used for the layout. Not only do tables make your markup ugly but they render slowly and make your code hard to maintain. Do not use tables for your layout!</p>
<h2>Make classes and IDs with capital letters</h2>
<p>The CSS can become terribly hard to maintain if you have some capital letters in your classes &amp; IDs. Just don&#8217;t do it.</p>
<h2>Make inline JavaScript and CSS</h2>
<p>Writing JavaScript and CSS in the HTML files is a bad idea, since every time you go to a page you have to re-download the CSS and JavaScript if they&#8217;re not external. If they are external browsers can cache them and will not have to load them again.</p>
<p>I hope you enjoyed these tips. Am I missing something? Leave a comment below telling me what it is.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://html-tricks.com/general/10-things-to-avoid/&amp;title=5+Things+Not+to+Do+While+Web+Coding" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=5+Things+Not+to+Do+While+Web+Coding+-+http://bit.ly/c8eoVF&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://html-tricks.com/general/10-things-to-avoid/&amp;title=5+Things+Not+to+Do+While+Web+Coding" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://html-tricks.com/general/10-things-to-avoid/&amp;title=5+Things+Not+to+Do+While+Web+Coding" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://html-tricks.com/general/10-things-to-avoid/&amp;title=5+Things+Not+to+Do+While+Web+Coding" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://html-tricks.com/general/10-things-to-avoid/&amp;t=5+Things+Not+to+Do+While+Web+Coding" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml-tricks.com%2Fgeneral%2F10-things-to-avoid%2F&amp;t=5+Things+Not+to+Do+While+Web+Coding" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://html-tricks.com/general/10-things-to-avoid/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://html-tricks.com/general/10-things-to-avoid/&amp;title=5+Things+Not+to+Do+While+Web+Coding" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://html-tricks.com/general/10-things-to-avoid/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://html-tricks.com/general/10-things-to-avoid/&amp;h=5+Things+Not+to+Do+While+Web+Coding" rel="nofollow" class="external" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://html-tricks.com/general/10-things-to-avoid/&amp;t=5+Things+Not+to+Do+While+Web+Coding" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://html-tricks.com/general/10-things-to-avoid/&amp;title=5+Things+Not+to+Do+While+Web+Coding&amp;description=%0D%0A%0D%0ACreating%20websites%20is%20a%20complicated%20process%20and%20many%20coders%20can%20develop%20bad%20practices%20while%20creating%20them.%20Here%27s%205%20things%20not%20to%20do%20while%20web%20coding.%0D%0A%0D%0AUse%20a%20transitional%20doctype%0D%0AUsing%20the%20HTML%204.01%20%22loose%22%20doctype%20or%20the%20XHTML%201.0%20Transitional%20doctype%20is%20a%20bad%20way%20to%20start%20a%20website.%20Instead%2C" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://html-tricks.com/general/10-things-to-avoid/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Optimizing Your PHP Apps</title>
		<link>http://html-tricks.com/php/optimizing/</link>
		<comments>http://html-tricks.com/php/optimizing/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 14:41:24 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://html-tricks.com/?p=293</guid>
		<description><![CDATA[PHP is a very complex language and unfortunately at times it can be quite slow. Here are some easy things you can do that can speed up your application. Stop using foreach() foreach() has been proven by several benchmarks to be extremely slow. Do not use it under any circumstances. Here&#8217;s an example of an [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://html-tricks.com/wp-content/uploads/2010/06/gear.png" alt="" title="Optimizing PHP Apps" width="256" height="256" class="aligncenter size-full wp-image-294" /></p>
<p>PHP is a very complex language and unfortunately at times it can be quite slow. Here are some easy things you can do that can speed up your application.<br />
<span id="more-293"></span></p>
<h2>Stop using foreach()</h2>
<p><a href="http://www.php.net/manual/en/control-structures.foreach.php">foreach()</a> has been proven by several benchmarks to be extremely slow. Do <em>not</em> use it under any circumstances. Here&#8217;s an example of an inefficient piece of code which uses foreach():</p>
<pre class="brush: php;">
$myArray = array(1, 2, 3, 4);
foreach ($myArray as $value) {
     echo $value;
}
</pre>
<p>Instead, just use regular <a href="http://www.php.net/manual/en/control-structures.for.php">for</a>.</p>
<pre class="brush: php;">
$myArray = array(1, 2, 3, 4);
$amount = count($myArray);
for ($i = 0; $i &lt;= $amount; $i++) {
    echo $myArray[$i];
}
</pre>
<p>They do exactly the same thing, but the second one is <strong>much</strong> faster.</p>
<h2>Avoid Double Quotes</h2>
<p>Double quotes (&#8221; &#8220;) should only be used when needed, otherwise you should use single quotes. Double quotes search for variables within the string which takes up time; and if there&#8217;s no variables within the string then it&#8217;s pointless to use double quotes.</p>
<h2>Use echo Efficiently</h2>
<p>If you do this:</p>
<pre class="brush: php; light: true;">echo &quot;Hello&quot; . $myVar;</pre>
<p>PHP has to concatenate &#8220;Hello&#8221; and the value of $myVar, and then output it.</p>
<p>However, if you use a comma like this:</p>
<pre class="brush: php; light: true;">echo &quot;Hello&quot;, $myVar;</pre>
<p>PHP does not have to concatenate the &#8220;Hello&#8221; and $myVar, instead it just outputs both of them.</p>
<h2>Calculate the array size before hand</h2>
<p>I often see code like this:</p>
<pre class="brush: php;">
$myArray = array(1, 2, 3, 4);
for ($i = 0; $i &lt;= count($myArray); $i++) {
    echo $myArray[$i];
}
</pre>
<p>The problem? Every iteration $myArray is recounted. This is a huge waste of time. Instead, use this:</p>
<pre class="brush: php;">
$myArray = array(1, 2, 3, 4);
$amount = count($myArray);
for ($i = 0; $i &lt;= $amount; $i++) {
    echo $myArray[$i];
}
</pre>
<h2>Install APC</h2>
<p>APC, or <a href="http://php.net/manual/en/book.apc.php">Alternative PHP Cache</a> is a free addon to PHP which speeds up PHP by caching its opcodes. I highly recommend it for any site with a large audience.</p>
<p>So there you have it, 5 easy ways to make your application run faster, I hope these helped you and make sure to leave a comment!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://html-tricks.com/php/optimizing/&amp;title=Optimizing+Your+PHP+Apps" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Optimizing+Your+PHP+Apps+-+http://bit.ly/bOG4pA&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://html-tricks.com/php/optimizing/&amp;title=Optimizing+Your+PHP+Apps" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://html-tricks.com/php/optimizing/&amp;title=Optimizing+Your+PHP+Apps" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://html-tricks.com/php/optimizing/&amp;title=Optimizing+Your+PHP+Apps" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://html-tricks.com/php/optimizing/&amp;t=Optimizing+Your+PHP+Apps" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml-tricks.com%2Fphp%2Foptimizing%2F&amp;t=Optimizing+Your+PHP+Apps" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://html-tricks.com/php/optimizing/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://html-tricks.com/php/optimizing/&amp;title=Optimizing+Your+PHP+Apps" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://html-tricks.com/php/optimizing/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://html-tricks.com/php/optimizing/&amp;h=Optimizing+Your+PHP+Apps" rel="nofollow" class="external" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://html-tricks.com/php/optimizing/&amp;t=Optimizing+Your+PHP+Apps" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://html-tricks.com/php/optimizing/&amp;title=Optimizing+Your+PHP+Apps&amp;description=%0D%0A%0D%0APHP%20is%20a%20very%20complex%20language%20and%20unfortunately%20at%20times%20it%20can%20be%20quite%20slow.%20Here%20are%20some%20easy%20things%20you%20can%20do%20that%20can%20speed%20up%20your%20application.%0D%0A%0D%0AStop%20using%20foreach%28%29%0D%0Aforeach%28%29%20has%20been%20proven%20by%20several%20benchmarks%20to%20be%20extremely%20slow.%20Do%20not%20use%20it%20under%20any%20circumstances.%20Here%27s%20an" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://html-tricks.com/php/optimizing/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>(X)HTML Templates</title>
		<link>http://html-tricks.com/html/templates/</link>
		<comments>http://html-tricks.com/html/templates/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 12:31:23 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://html-tricks.com/?p=282</guid>
		<description><![CDATA[I often find myself writing the same code over and over for each new HTML or XHTML document I start. Below are some templates for various doctypes which you can copy and paste into any new (X)HTML documents you are creating. All of these validate. HTML 4.01 Strict &#60;!DOCTYPE HTML PUBLIC &#34;-//W3C//DTD HTML 4.01//EN&#34; &#34;http://www.w3.org/TR/html4/strict.dtd&#34;&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>I often find myself writing the same code over and over for each new HTML or XHTML document I start. Below are some templates for various doctypes which you can copy and paste into any new (X)HTML documents you are creating. All of these validate.<br />
<span id="more-282"></span></p>
<h2>HTML 4.01 Strict</h2>
<pre class="brush: xml;">
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Title&lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Content&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>HTML5</h2>
<pre class="brush: xml;">
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Title&lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Content&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>XHTML 1.0 Strict</h2>
<pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt;Title&lt;/title&gt;
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;application/xhtml+xml; charset=UTF-8&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Content&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>XHTML 1.1</h2>
<pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt;Title&lt;/title&gt;
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;application/xhtml+xml; charset=UTF-8&quot; /&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Content&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>We hope these templates save you some time!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://html-tricks.com/html/templates/&amp;title=%28X%29HTML+Templates" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=%28X%29HTML+Templates+-+http://bit.ly/diQrrw&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://html-tricks.com/html/templates/&amp;title=%28X%29HTML+Templates" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://html-tricks.com/html/templates/&amp;title=%28X%29HTML+Templates" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://html-tricks.com/html/templates/&amp;title=%28X%29HTML+Templates" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://html-tricks.com/html/templates/&amp;t=%28X%29HTML+Templates" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml-tricks.com%2Fhtml%2Ftemplates%2F&amp;t=%28X%29HTML+Templates" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://html-tricks.com/html/templates/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://html-tricks.com/html/templates/&amp;title=%28X%29HTML+Templates" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://html-tricks.com/html/templates/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://html-tricks.com/html/templates/&amp;h=%28X%29HTML+Templates" rel="nofollow" class="external" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://html-tricks.com/html/templates/&amp;t=%28X%29HTML+Templates" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://html-tricks.com/html/templates/&amp;title=%28X%29HTML+Templates&amp;description=I%20often%20find%20myself%20writing%20the%20same%20code%20over%20and%20over%20for%20each%20new%20HTML%20or%20XHTML%20document%20I%20start.%20Below%20are%20some%20templates%20for%20various%20doctypes%20which%20you%20can%20copy%20and%20paste%20into%20any%20new%20%28X%29HTML%20documents%20you%20are%20creating.%20All%20of%20these%20validate.%0D%0A%0D%0AHTML%204.01%20Strict%0D%0A%5Bhtml%5D%0D%0A%26lt%3B%21DOCTYPE%20HTML%20PUBLI" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://html-tricks.com/html/templates/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>CSS3 Alternatives for IE</title>
		<link>http://html-tricks.com/css/css3-alternatives-for-ie/</link>
		<comments>http://html-tricks.com/css/css3-alternatives-for-ie/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 21:11:10 +0000</pubDate>
		<dc:creator>Andrew</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://html-tricks.com/?p=238</guid>
		<description><![CDATA[Even with the upcoming release of Internet Explorer 9, which will theoretically have CSS3 support, a lot of people are guaranteed not to upgrade. There are many cool features made easy in CSS3 that are still available to these users. We&#8217;re going to cover the big ones. Rounded Corners Everybody loves rounded corners. But Internet [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://html-tricks.com/wp-content/uploads/2010/06/css3ie.png" alt="" title="CSS3 IE Alternatives" width="280" height="280" class="aligncenter size-full wp-image-276" /><br />
Even with the upcoming release of Internet Explorer 9, which will theoretically have CSS3 support, a lot of people are guaranteed not to upgrade. There are many cool features made easy in CSS3 that are still available to these users. We&#8217;re going to cover the big ones.<br />
<span id="more-238"></span></p>
<h2>Rounded Corners</h2>
<p>Everybody loves rounded corners. But Internet Explorer 8 and below does not support this at all. Luckily <a href="http://www.curvycorners.net/">Curvy Corners</a> makes cross-browser round corners easy. It uses CSS3 on browsers that have it and JavaScript on those which don&#8217;t.</p>
<h2>Box Shadows</h2>
<p>Due to an IE specific script, box shadows are easy to create on Internet Explorer.</p>
<pre class="brush: css;">
.box-shadow {
	box-shadow: 10px 10px 20px #000; /* Define the regular box shadow */
	behavior: url('ie-css3.htc'); /* Include the IE script */
}
</pre>
<p><a href='http://html-tricks.com/wp-content/uploads/2010/06/ie-css3.htc'>Download ie-css3.htc</a></p>
<p>Just make sure you put the <em>ie-css3.htc</em> in the same directory as the CSS file, and don&#8217;t forget to add the -moz- and -webkit- prefixes for other browsers!</p>
<h2>Selectors</h2>
<p>CSS3 introduces a lot of nice selectors, but Internet Explorer 8 and below supports none of them. Fortunately, there is a script which adds a lot of the cool CSS3 selectors to IE. Just download the script from <a href="http://www.webresourcesdepot.com/use-css3-pseudo-selectors-with-ie-ie-css3-js/">here</a> and link to it in your HTML code.</p>
<h2>Gradients</h2>
<p>Gradients in Internet Explorer are surprisingly simple using their proprietary &#8220;filter&#8221; property.</p>
<pre class="brush: css;">
.gradient {
    filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#FFFFFF, endColorstr=#000000);
}
</pre>
<p>You can replace #FFFFFF with the first color and #000000 with the other color.<br />
<br />Things made possible by CSS3 are certainly available in Internet Explorer if you take the time to support IE. So the question is, is it worth giving IE users the same eye candy as Firefox, Webkit and Opera users?</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-enjoy">
<ul class="socials">
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://html-tricks.com/css/css3-alternatives-for-ie/&amp;title=CSS3+Alternatives+for+IE" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=CSS3+Alternatives+for+IE+-+http://bit.ly/ckBQHn&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://html-tricks.com/css/css3-alternatives-for-ie/&amp;title=CSS3+Alternatives+for+IE" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://html-tricks.com/css/css3-alternatives-for-ie/&amp;title=CSS3+Alternatives+for+IE" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://html-tricks.com/css/css3-alternatives-for-ie/&amp;title=CSS3+Alternatives+for+IE" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://html-tricks.com/css/css3-alternatives-for-ie/&amp;t=CSS3+Alternatives+for+IE" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fhtml-tricks.com%2Fcss%2Fcss3-alternatives-for-ie%2F&amp;t=CSS3+Alternatives+for+IE" rel="nofollow" class="external" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://html-tricks.com/css/css3-alternatives-for-ie/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-slashdot">
			<a href="http://slashdot.org/bookmark.pl?url=http://html-tricks.com/css/css3-alternatives-for-ie/&amp;title=CSS3+Alternatives+for+IE" rel="nofollow" class="external" title="Submit this to SlashDot">Submit this to SlashDot</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://html-tricks.com/css/css3-alternatives-for-ie/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-newsvine">
			<a href="http://www.newsvine.com/_tools/seed&amp;save?u=http://html-tricks.com/css/css3-alternatives-for-ie/&amp;h=CSS3+Alternatives+for+IE" rel="nofollow" class="external" title="Seed this on Newsvine">Seed this on Newsvine</a>
		</li>
		<li class="shr-hackernews">
			<a href="http://news.ycombinator.com/submitlink?u=http://html-tricks.com/css/css3-alternatives-for-ie/&amp;t=CSS3+Alternatives+for+IE" rel="nofollow" class="external" title="Submit this to Hacker News">Submit this to Hacker News</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://html-tricks.com/css/css3-alternatives-for-ie/&amp;title=CSS3+Alternatives+for+IE&amp;description=%0D%0AEven%20with%20the%20upcoming%20release%20of%20Internet%20Explorer%209%2C%20which%20will%20theoretically%20have%20CSS3%20support%2C%20a%20lot%20of%20people%20are%20guaranteed%20not%20to%20upgrade.%20There%20are%20many%20cool%20features%20made%20easy%20in%20CSS3%20that%20are%20still%20available%20to%20these%20users.%20We%27re%20going%20to%20cover%20the%20big%20ones.%0D%0A%0D%0ARounded%20Corners%0D%0AEverybody" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://html-tricks.com/css/css3-alternatives-for-ie/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->