<?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"
	>

<channel>
	<title>Developer Tutorials' Webmaster Blog &#187; PHP</title>
	<atom:link href="http://www.developertutorials.com/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.developertutorials.com/blog</link>
	<description>Keeping webmasters up-to-date on technology.</description>
	<pubDate>Tue, 08 Jul 2008 09:00:52 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Wordpress Comment Styling Round Up</title>
		<link>http://www.developertutorials.com/blog/php/wordpress-comment-styling-round-up-211/</link>
		<comments>http://www.developertutorials.com/blog/php/wordpress-comment-styling-round-up-211/#comments</comments>
		<pubDate>Fri, 30 May 2008 22:35:05 +0000</pubDate>
		<dc:creator>JonGos</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[comments]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/wordpress-comment-styling-round-up-211/</guid>
		<description><![CDATA[One question I hear people asking a lot is how to style the comment section in Wordpress. I didn&#8217;t have time to go in depth in my tutorial Designing and Coding a Wordpress Theme from Scratch but here are a few links from my del.icio.us to some blogs that break it down in far more [...]]]></description>
			<content:encoded><![CDATA[<p>One question I hear people asking a lot is how to style the comment section in Wordpress. I didn&#8217;t have time to go in depth in my tutorial <a href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-4-147/">Designing and Coding a Wordpress Theme from Scratch</a> but here are a few links from my <a href="http://del.icio.us/jongos/">del.icio.us</a> to some blogs that break it down in far more detail.</p>
<p><img src="http://farm3.static.flickr.com/2371/2537508016_31b69cb281.jpg"><br />
<span id="more-211"></span></p>
<p><b><a href="http://nettuts.com/news/unraveling-the-secrets-of-wordpress-commentsphp-file/">NETTUTS: &#8220;Unraveling the Secrets Of the comments.php File&#8221;</a></b></p>
<p>One of the best tutorials I&#8217;ve ever seen related to customizing comments for Wordpress.  Great for beginners because the explain EVERYTHING. </p>
<p><b><a href="http://www.darrenhoyt.com/2007/08/18/styling-your-wordpress-comments/">DARREN HOYT: &#8220;Styling Your Wordpress Comments&#8221;</a></b></p>
<p>Darren&#8217;s breakdown is a little bit less obtuse but gets the job done.</p>
<p><b><a href="http://5thirtyone.com/archives/774">5THIRTY-ONE: &#8220;How To Style Wordpress Author Comments&#8221;</a></b></p>
<p>One of my favorite Wordpress designers makes his case.</p>
<p><b><a href="http://www.themelab.com/2008/05/09/add-gravatar-support-to-your-wordpress-comments/">THEMELAB: &#8220;Add Gravatar Support to Your Wordpress Comments&#8221;</a></b></p>
<p>Very basic guide on how to add images for your users.</p>
<p><b><a href="http://www.tamba2.org.uk/wordpress/commentstyling/">TAMBA2: &#8220;Comment Styling&#8221;</a></b></p>
<p>Tamba2&#8217;s is a little old but still useful.</p>
<p><b><a href="http://codex.wordpress.org/User:Matt/photomatt.net/wp-comments.php">PHOTOMATT: &#8220;Display Comment Numbers&#8221;</a></b></p>
<p>This snippet of code from Photomatt is useful if you want to learn how to add numbers to your comments.</p>
<p><b><a href="http://www.coldforged.org/archives/2005/04/19/coldforgeds-wordpress-comment-template-deconstructed-part-1/">COLORFORGE: &#8220;Comment Template Deconstructed&#8221;</a></b></p>
<p>Wow, this guys comment template is incredibly beautiful and complex!  Very much worth checking out.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d211').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d211" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/wordpress-comment-styling-round-up-211/&amp;title=Wordpress+Comment+Styling+Round+Up" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/wordpress-comment-styling-round-up-211/&amp;title=Wordpress+Comment+Styling+Round+Up" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/wordpress-comment-styling-round-up-211/&amp;title=Wordpress+Comment+Styling+Round+Up" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/wordpress-comment-styling-round-up-211/&amp;title=Wordpress+Comment+Styling+Round+Up" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d211').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/wordpress-comment-styling-round-up-211/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Designing and Coding a Wordpress Theme From Scratch (Part 10)</title>
		<link>http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-10-160/</link>
		<comments>http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-10-160/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 21:16:50 +0000</pubDate>
		<dc:creator>JonGos</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Photoshop]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[theme]]></category>

		<category><![CDATA[wordpress]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-10-160/</guid>
		<description><![CDATA[Going From Photoshop to XHTML to Wordpress Theme.  In this multi-part series I'll detail how to create and design a Wordpress theme in Photoshop and take it from just an idea to fully coded.
]]></description>
			<content:encoded><![CDATA[<p><a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-3-146/">Part 3</a> - &#8220;Photoshop to XHTML in 24 Hours&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-4-147/">Part 4</a> - &#8220;Cleaning Up Your XHTML&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/javascript/designing-and-coding-a-wordpress-theme-from-scratch-part-5-149/">Part 5</a> - &#8220;Preloading Images with Javascript and CSS&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-6-151/">Part 6</a> - &#8220;Marking Up is Hard to Do&#8221; and &#8220;The Anatomy of a Wordpress Theme&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/">Part 7</a> - &#8220;Beginning with PHP for Wordpress&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-8-154/">Part 8</a> - &#8220;Putting the Press in Wordpress with PHP&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/php/designing-and-…scratch-part-9designing-and-coding-a-wordpress-theme-from-scratch-part-9-159/">Part 9</a> - &#8220;Marking Up Header.php, Footer.php and Sidebar.php&#8221;</p>
<p>So far we&#8217;ve made a ton of progress with our theme design.  We <a href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-2-144/" target="_blank" title="designing wordpress themes in photoshop">designed it</a> in Photoshop, we <a href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-4-147/" target="_blank" title="XHTML CSS to Wordpress theme">converted to XHTML</a> and then we began the somewhat tedious task of <a href="http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/" target="_blank" title="XHTML to PHP">adding PHP</a>.  Now that we&#8217;ve created index.php, header.php, footer.php and sidebar.php, we can move on to creating the rest of the theme.</p>
<p><span id="more-160"></span></p>
<p>In &#8220;The Anatomy of a Wordpress Theme&#8221; we noted that Wordpress needs <a href="http://www.wpdesigner.com/2007/03/27/wordpress-theme-checklist/" target="_blank">certain files</a> for your theme to function properly.  Here&#8217;s that list again:</p>
<ol>
<li>404 Template = 404.php</li>
<li><strike>Archive Template</strike> = <a href="http://codex.wordpress.org/Creating_an_Archive_Index" target="_blank">archive.php</a></li>
<li><strike>Archive Index Page</strike> = <a href="http://codex.wordpress.org/Creating_an_Archive_Index" title="_blank">archives.php</a></li>
<li>Comments Template = <a href="http://www.christianmontoya.com/2006/10/15/full-featured-commentsphp-template-for-wordpress/" target="_blank">comments.php</a></li>
<li><strong>Footer Template = footer.php</strong></li>
<li><strong>Header Template = header.php</strong></li>
<li>Links = links.php</li>
<li><strong>Main Template = index.php</strong></li>
<li>Page Template = page.php</li>
<li><strike>Popup Comments Template</strike> = <a href="http://codex.wordpress.org/Theme_Development" target="_blank">comments-popup.php</a></li>
<li>Post Template = single.php</li>
<li><strike>Search Form</strike> = <a href="http://codex.wordpress.org/search.php" target="_blank">searchform.php</a></li>
<li><strike>Search Template</strike> = <a href="" target="_blank">search.php</a></li>
<li><strong>Sidebar Template = sidebar.php</strong></li>
<li><strong>Stylesheet = style.css</strong></li>
</ol>
<p>As you may have noticed, the items listed in <strong>bold</strong> are the only items we&#8217;ve created in our lessons thus far and there is still a lot of work to be done!  Anything <strike>struck through</strike> is optional therefore this lesson won&#8217;t cover it but I have linked to pages where you can read about them on your own. While I can&#8217;t go into complete detail I will highlight some major points about each and then I&#8217;ll give you links to four sites that break the process down in detail and more thoroughly:</p>
<h2>single.php</h2>
<p>Single.php is the file referenced when someone clicks on the permalink for one of your posts.  Thus it is the template for displaying a single post on your blog.  On most blogs single.php an index.php are very similar except that in addition to querying <strong>&lt;? the content(); ?&gt;</strong> we also have to query the comments page. We do this just before we close the loop with:</p>
<pre>
	&lt;?php comments_template(); ?&gt;
</pre>
<p><b>page.php</b></p>
<p>Page.php is the template for any page in your theme that doesn&#8217;t have it&#8217;s own .php template or that is not a blog entry.  This is also the template for the static &#8220;Pages&#8221; that you create within the Wordpress Admin panel.  It is usually also just like index.php except that it doesn&#8217;t include <strong>the loop</strong> or <strong>the_content()</strong>.</p>
<p><b>links.php</b></p>
<p>Ignores Page content and instead displays your links using <strong>get_links_list</strong>.</p>
<h2>404.php</h2>
<p>Where you users land when they follow a bad link on your blog or click through to something that&#8217;s been removed.  <a href="http://codex.wordpress.org/Creating_an_Error_404_Page" target="blank">Codex</a> offers some advice&#8230;. </p>
<blockquote cite="http://codex.wordpress.org/Creating_an_Error_404_Page"><p>
While you work hard to make sure that every link actually goes to a specific web page on your site, there is always a chance that a link clicked will slam dunk and become a famous 404 ERROR PAGE NOT FOUND. Some errors are avoidable, you should regularly check and double check all your links. Also, if you are deleting a popular but out-of-date post, consider deleting the body of the post, and replacing it with a link referring visitors to the new page.
</p>
</blockquote>
<p>This concludes <a href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-3-146/">&#8220;Designing and Coding a Wordpress theme from Scratch&#8221;</a> .  This guide was written as a starting point and a reference guide I can always be contacted at <strong>jongos [at] gmail</strong> if you are having trouble or need advice.  Alternatively I&#8217;ve compiled a list of resources that I often reference when creating themes below.</p>
<p>In this tutorial I mentioned a theme that I was developing quite a bit.  You can download it along with the PSD used to create it <a href="http://www.developertutorials.com/blog/wp-content/uploads/2008/04/aqua-marina.zip" target="_blank">here</a>.  Keep in mind that the version you&#8217;re downloading is an early beta release.  It&#8217;s bulky, clunky, not very pretty under the covers and has a mind of it&#8217;s own so I&#8217;m dubbing it the Rosie O Donnell release.  Feel free to give me feedback on it, use it to double check your own code, or modify it to suit your needs.</p>
<p><strong>DOWNLOAD THE <a href="http://www.developertutorials.com/blog/wp-content/uploads/2008/04/aqua-marina.zip" target="_blank">AQUA MARINA</a> WORDPRESS THEME</strong></p>
<p><a href="http://goscreative.blogspot.com/2008/05/free-wordpress-theme-aqua-marina.html" target="_blank"><img src="http://farm3.static.flickr.com/2001/2449394258_676eb5ea2b_m.jpg"></a></p>
<hr />
<b>Recommended Further Reading</b></p>
<p><a target="_blank" title="understanding wordpress templates" rel="bookmark" href="http://codex.wordpress.org/">Stepping_Into_Templates</a><br />
<a target="_blank" title="html to xhtml" rel="bookmark" href="http://codex.wordpress.org/HTML_to_XHTML">HTML to XHTML</a><br />
<a target="_blank" title="create wordpress themes" rel="bookmark" href="http://www.wpdesigner.com/2007/02/19/so-you-want-to-create-wordpress-themes-huh/">So You Want To Create Wordpress Themes</a><br />
<a target="_blank" title="xhtml css to wordpress" rel="bookmark" href="http://theundersigned.net/2006/05/from-xhtmlcss-to-wordpress/">From XHTML/CSS to Wordpress</a><br />
<a href="http://www.tamba2.org.uk/wordpress/" target="_blank" title="tamba2 wordpress tutorials">Tamba2&#8217;s Guide</a><br />
<a href="http://www.wpdesigner.com/2007/08/10/how-to-slice-a-wordpress-theme/" target="_blank" title="Slicing a Wordpress Theme">Slizing a Wordpress Theme</a></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d160').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d160" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-10-160/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+10%29" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-10-160/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+10%29" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-10-160/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+10%29" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-10-160/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+10%29" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d160').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-10-160/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Learn regular expressions in PHP</title>
		<link>http://www.developertutorials.com/blog/php/learn-regular-expressions-in-php-152/</link>
		<comments>http://www.developertutorials.com/blog/php/learn-regular-expressions-in-php-152/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 11:00:04 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/learn-regular-expressions-in-php-152/</guid>
		<description><![CDATA[Love them or hate them, regular expressions are here to stay. When it comes to quickly dealing with large blocks of data, batch processing operations or screen scraping, regular expressions are often the most effective solution. There&#8217;s just one problem, though - learning them can be as hard as learning a new language altogether. Here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Love them or hate them, regular expressions are here to stay. When it comes to quickly dealing with large blocks of data, batch processing operations or screen scraping, regular expressions are often the most effective solution. There&#8217;s just one problem, though - learning them can be as hard as learning a new language altogether. Here&#8217;s how to get off to a flying start.</p>
<p><span id="more-152"></span></p>
<p>First, you need to how regular expressions work. Stick with PCRE - the preg_* functions - they&#8217;re faster, more reliable and expressions for them are more common. The different styles of regular expressions each define a mini language for matching patterns within a block of text. Screen scraping is probably the most popular example. Consider this:</p>

<div class="wp_syntax"><div class="code"><pre>&lt;a href=&quot;http://example.com/1&quot;&gt;1&lt;/a&gt;
&lt;a href=&quot;http://example.com/2&quot;&gt;Not 1.&lt;/a&gt;
&lt;a href=&quot;http://example.com/?query#someid&quot;&gt;Yet another link.&lt;/a&gt;</pre></div></div>

<p>What if you wanted to programmatically extract the link URLs and text from each of these? At this level of simplicty, some basic explode()s might be enough, and when you need to be more tolerant for the data, XML parsing is probably the way to go. But for now, just looking at that, regular expressions would be the easiest way. And we can build a pattern that defines what is to be matched so that the regular expression engine (in this case, PCRE) will find all matches and give them to us.</p>
<p>One of the best ways to understand regular expressions in practise, I find, is to consider mod_rewrite. You&#8217;ve seen those fantastic URLs on websites - e.g. http://example.com/users/myusername - these don&#8217;t actually exist as a file, but we can use Apache&#8217;s mod_rewrite engine to &#8220;rewrite&#8221; these URLs to other URLs. We might make that /users/(some username) go to /users.php?username=(the username). The best tutorial for this, by far, is <a href="http://corz.org/serv/tricks/htaccess2.php" target="_blank">the corz.org htaccess tips and tricks</a> guide. Have a very thorough read through this and experiment with it extensively before you go on.</p>
<p>Next, get equipped to test out regular expressions. You&#8217;re probably using Firefox. If you aren&#8217;t, <a href="http://getfirefox.com/" target="_blank">get it</a>. Then get the <a href="http://sebastianzartner.de/firefoxExtensions/RExT/" target="_blank">Regular Expressions Tester Firefox extension</a>. This will be invaluable for experimenting with regular expressions - the best way to learn.</p>
<p>Of course, you&#8217;ll need to be familiar with the PHP functions that will provide your regular expression workhorse. Bookmark <a href="http://www.developertutorials.com/php-manual/function.preg-match.html" target="_blank">the preg_match function&#8217;s manual entry</a> and refer back to it as you need to. The manual page has some invaluable examples which you should read through extensively.</p>
<p>Finally, when in doubt, keep a cheatsheet at hand. <a href="http://www.ilovejackdaniels.com/cheat-sheets/regular-expressions-cheat-sheet/">ILoveJackDaniels.com</a> has a fantastic <a href="http://www.ilovejackdaniels.com/regular_expressions_cheat_sheet.png" target="_blank">regular expression cheatsheet</a> that you should also bookmark.</p>
<p>With all these ready, you&#8217;ll be off to a great start. Remember, the best way to learn is to practise &#8212; read through real, working code, then write your own. Once you&#8217;ve finished all this, you&#8217;ll be a regular expression whiz in no time.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d152').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d152" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/learn-regular-expressions-in-php-152/&amp;title=Learn+regular+expressions+in+PHP" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/learn-regular-expressions-in-php-152/&amp;title=Learn+regular+expressions+in+PHP" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/learn-regular-expressions-in-php-152/&amp;title=Learn+regular+expressions+in+PHP" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/learn-regular-expressions-in-php-152/&amp;title=Learn+regular+expressions+in+PHP" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d152').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/learn-regular-expressions-in-php-152/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Designing and Coding a Wordpress Theme From Scratch (Part 7)</title>
		<link>http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/</link>
		<comments>http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 13:51:45 +0000</pubDate>
		<dc:creator>JonGos</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[PHP Functions]]></category>

		<category><![CDATA[Photoshop]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[Design]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[theme]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/</guid>
		<description><![CDATA[Going From Photoshop to XHTML to Wordpress Theme.  In this multi-part series I'll detail how to create and design a Wordpress theme in Photoshop and take it from just an idea to fully coded.
]]></description>
			<content:encoded><![CDATA[<p>This is the seventh post in series about creating Wordpress themes with your Photoshop designs.  You may want to review before we continue&#8230;.</p>
<p><a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-1-143/">Part 1</a> - &#8220;Tools For The Task&#8221; and &#8220;Preparation&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-2-144/">Part 2</a> - &#8220;Layout And Structure&#8221; and &#8220;Designing Wordpress Themes in Photoshop&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-3-146/">Part 3</a> - &#8220;Photoshop to XHTML in 24 Hours&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-4-147/">Part 4</a> - &#8220;Cleaning Up Your XHTML&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/javascript/designing-and-coding-a-wordpress-theme-from-scratch-part-5-149/">Part 5</a> - &#8220;Preloading Images with Javascript and CSS&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-6-151/">Part 6</a> - &#8220;Marking Up is Hard to Do&#8221; and &#8220;The Anatomy of a Wordpress Theme&#8221;</p>
</p>
<hr style="margin-bottom:20px; height:1px; color:#cccccc;"/>
<b>Beginning with PHP for WordPress</b></p>
<ul>
<li>First we&#8217;ll duplicate <strong>index.html</strong> and rename the copy <strong>index.php</strong>.  We&#8217;re only keeping the original .html file for reference to make sure that the finished PHP operates and looks the same.</li>
<li>Let&#8217;s open index.php in our text editor.  Right now it&#8217;s just a .html renamed .php.  Our job is to make make it true PHP.</li>
<p><span id="more-153"></span></p>
<li>Go ahead and create some more blank documents in your theme folder.  Let&#8217;s call them header.php, footer.php and sidebar.php (if you have a side bar in your theme).  We&#8217;re going to divide the HTML into the major sections and make each section it&#8217;s own PHP file to be marked up separately.</li>
<li>Cut everything that you consider the header of your document.  Make sure all tags are closed.  Below you&#8217;ll find an example of my code which is really irrelevant, your own code will look and function differently based on your unique design. Still, for the sake of a working example:</li>
<pre>
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;title&gt;The Wonderful World of Web Design!&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;link rel="stylesheet" href="style.css" type="text/css" media="screen" /&gt;
&lt;script type="text/javascript" src="scripts/preload.js"&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div id="container"&gt;
	&lt;div id="header"&gt;
    &lt;div class="description"&gt;The Blog Title&lt;/span&gt;&lt;/div&gt;
	&lt;/div&gt;
    &lt;div id="header-nav"&gt;&lt;div class="content"&gt;
    &lt;a href=""&gt;ADVERTISE&lt;/a&gt;  |
    &lt;a href=""&gt;CONTACT&lt;/a&gt;  |
    &lt;a href=""&gt;RSS&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
    &lt;div id="spacer1"&gt;&lt;/div&gt;
    &lt;div id="upper-menu"&gt;&lt;div class="navigation"&gt;
    &lt;a href=""&gt;HOME&lt;/a&gt;
    &lt;a href=""&gt;NEWS&lt;/a&gt;
    &lt;a href=""&gt;BLOG&lt;/a&gt;
    &lt;a href=""&gt;HIRE ME&lt;/a&gt;
    &lt;a href=""&gt;PORTFOLIO&lt;/a&gt;
    &lt;a href=""&gt;QUESTIONS&lt;/a&gt;
    &lt;a href=""&gt;LINKS&lt;/a&gt;
    &lt;a href=""&gt;POPULAR&lt;/a&gt;
    &lt;/div&gt;

    &lt;/div&gt;
	&lt;div id="right-top"&gt;&lt;/div&gt;

 &lt;!-- End header.php --&gt;
</pre>
<li>Paste your header information in to header.php.  Do the same for sidebar and your footer, cutting the code from index.php and pasting it in the corresponding file.</li>
<li>I use comment tags like <strong>&lt;!&#8211; End header.php &#8211;&gt;</strong> to write notes that help me remember what&#8217;s going on in my code.</li>
<li>If you do this correctly you&#8217;ll be left with a pretty sparse index.php document.  All that should be left is some That&#8217;s good because now we&#8217;re going to tell index.php where to find all the information we just moved.  We do this with PHP functions like so:</li>
<pre>
&lt;?php get_phpdocumentname(); ?&gt;
</pre>
<p>This <strong>get_</strong> function does exactly what it sounds like it goes and fetches a requested document and displays the contents of that document in the area requested.  My index.php document looked like this:</p>
<pre>
&lt;?php get_header(); ?&gt;

    &lt;/div&gt;

	&lt;div id="post"&gt;
	  &lt;div class="entry"&gt;

		&lt;div class="posts"&gt;
     		&lt;/div&gt;   

	  &lt;/div&gt;
	&lt;/div&gt;

&lt;?php get_footer(); ?&gt;
</pre>
<li>Ofcourse, for now we&#8217;ll leave the body &lt;div&gt;&#8217;s empty.  This is where our content will eventually go.
<p>You&#8217;ll notice that I have no sidebar, that&#8217;s because I call for it in the header.php document instead.  Why?  Because browsers read code from top to bottom and I want page to request the header and side bars to first before requesting the body.</p>
<p>In the next lesson we&#8217;ll start to analyze the PHP functions needed to request and display the dynamic content of a Wordpress theme.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d153').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d153" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+7%29" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+7%29" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+7%29" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+7%29" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d153').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Designing and Coding a Wordpress Theme From Scratch (Part 6)</title>
		<link>http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-6-151/</link>
		<comments>http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-6-151/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 12:37:31 +0000</pubDate>
		<dc:creator>JonGos</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[theme]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-6-151/</guid>
		<description><![CDATA[Going From Photoshop to XHTML to Wordpress Theme.  In this multi-part series I'll detail how to create and design a Wordpress theme in Photoshop and take it from just an idea to fully coded.
]]></description>
			<content:encoded><![CDATA[<p>This is the sixth post in series about creating Wordpress themes with your Photoshop designs.  You may want to review before we continue&#8230;.</p>
<p><a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-1-143/">Part 1</a> - &#8220;Tools For The Task&#8221; and &#8220;Preparation&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-2-144/">Part 2</a> - &#8220;Layout And Structure&#8221; and &#8220;Designing Wordpress Themes in Photoshop&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-3-146/">Part 3</a> - &#8220;Photoshop to XHTML in 24 Hours&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-4-147/">Part 4</a> - &#8220;Cleaning Up Your XHTML&#8221;<br />
<a target="_blank" href="http://www.developertutorials.com/blog/javascript/designing-and-coding-a-wordpress-theme-from-scratch-part-5-149/">Part 5</a> - &#8220;Preloading Images with Javascript and CSS&#8221;</p>
<hr style="margin-bottom:20px; height:1px; color:#cccccc;"/>
<b>Marking Up Is Hard To Do</b></p>
<p>Wikipedia defines the term markup as <i>a set of annotations to text that describe how it is to be structured, laid out, or formatted.</i>  When we say we&#8217;re going to &#8216;mark something up&#8217; it means we&#8217;re formatting the document so that it can be read correctly by machines.  Hypertext Markup Language (HTML) is the most common form.  That can be marked up to Extensible Hyper-text Markup Language (XHTML) and beyond that to PHP to become dynamic.</p>
<p>Now that we&#8217;ve got our basic html layout design we can begin the hard work the transition from HTML to PHP.</p>
<p><span id="more-151"></span></p>
<p><b>Anatomy of a WordPress Theme</b></p>
<p>Before we get ahead of ourselves let&#8217;s analyze exactly what Wordpress is expecting from a theme.  The Wordpress engine works primarily using separate PHP files for the different components of the core engine. The various parts of your theme will simply call for various parts of the core engine to display content.  This makes it easy for you to style sections individually.  It also can allow for some incredibly complex themes that are built on the Wordpress engine.  Themes like the <a target="_blank" href="http://5thirtyone.com/archives/886">The Unstandard</a> by Derek Punsalan and <a target="_blank" href="http://www.deanjrobinson.com/redoable/redoable-10-theme-for-wordpress/">Redoable</a> are great examples of how to rethink the Wordpress theme impressively.</p>
<blockquote cite="http://codex.wordpress.org/Using_Themes"><p>Fundamentally, the WordPress Theme system is a way to &#8220;skin&#8221; your weblog. Yet, it is more than just a &#8220;skin.&#8221; Skinning your site implies that only the design is changed. WordPress Themes can provide much more control over the look and presentation of the material on your website.</p>
<p>A WordPress Theme is a collection of files that work together to produce a graphical interface with an underlying unifying design for a weblog. These files are called template files. A theme modifies the way the site is displayed, without modifying the underlying software. Themes may include customized template files, image files (*.jpg, *.gif), style sheets (*.css), custom Pages, as well as any necessary code files (*.php).</p>
</blockquote>
<p>Here are the things Wordpress looks for a theme file:</p>
<ol>
<li>404 Template = 404.php</li>
<li>Archive Template = archive.php</li>
<li>Archive Index Page = archives.php</li>
<li>Comments Template = comments.php</li>
<li>Footer Template = footer.php</li>
<li>Header Template = header.php</li>
<li>Links = links.php</li>
<li>Main Template = index.php</li>
<li>Page Template = page.php</li>
<li>Popup Comments Template = comments-popup.php</li>
<li>Post Template = single.php</li>
<li>Search Form = searchform.php</li>
<li>Search Template = search.php</li>
<li>Sidebar Template = sidebar.php</li>
<li>Stylesheet = style.css</li>
</ol>
<p>For the most part, if you&#8217;re missing any of these parts your theme either won&#8217;t work or won&#8217;t fully function the way Wordpress wants it to.  So far the only thing we&#8217;ve completed is <strong>stylesheet.css</strong> so where do the rest come from?  In <a href="http://www.developertutorials.com/blog/php/designing-and-coding-a-wordpress-theme-from-scratch-part-7-153/">Part 7</a> we&#8217;ll create <strong>index.php</strong> and start marking up our XHTML to PHP.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d151').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d151" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-6-151/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+6%29" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-6-151/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+6%29" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-6-151/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+6%29" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-6-151/&amp;title=Designing+and+Coding+a+Wordpress+Theme+From+Scratch+%28Part+6%29" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d151').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/design/designing-and-coding-a-wordpress-theme-from-scratch-part-6-151/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Iterating PHP objects, and readable code too!</title>
		<link>http://www.developertutorials.com/blog/php/iterating-php-objects-spl-iterato-150/</link>
		<comments>http://www.developertutorials.com/blog/php/iterating-php-objects-spl-iterato-150/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 12:22:17 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[PHP SPL]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/iterating-php-objects-spl-iterato-150/</guid>
		<description><![CDATA[Today I&#8217;m going to take a look at object iteration, most commonly found in the Standard PHP Library, and explore using the Iterator interface to simplify looping.

It&#8217;s a generally accepted fact that more readable code is more maintainable and easier for other developers to pick up. Simple scripts can be easily worked around these principles, [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;m going to take a look at object iteration, most commonly found in the <a target="_blank" href="http://www.developertutorials.com/php-manual/ref.spl.html">Standard PHP Library</a>, and explore using the Iterator interface to simplify looping.</p>
<p><span id="more-150"></span></p>
<p>It&#8217;s a generally accepted fact that more readable code is more maintainable and easier for other developers to pick up. Simple scripts can be easily worked around these principles, but the moment we explore any complexity the intricacies of the language impede basic readability - just look at the average Perl script, for example.</p>
<p>The <a target="_blank" href="http://www.developertutorials.com/php-manual/ref.spl.html">Standard PHP Library (SPL)</a> religiously utilises iteration for some outstanding results (and great code simplicity). PHP&#8217;s native language constructs are very readable, and by simplifying our code we can build applications faster and more effectively. The SPL demonstrates this with the power of its classes integrating with language constructs, such as the foreach loop.</p>
<p>Looping is probably one of the most common elements of PHP applications. Take this simple example, for instance:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #ff0000">$vegetables</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;tomato&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;carrot&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;cauliflower&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$vegetables</span> <span style="color: #b1b100;">as</span> <span style="color: #ff0000">$vegetable</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000">$vegetable</span> <span style="color: #66cc66;">.</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>As you can see, this is a very simple example, and probably doesn&#8217;t reflect a lot of the loops in your day-to-day development. They might look a little more like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$records</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$db</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$this</span><span style="color: #66cc66;">,</span> RECORDS_PER_PAGE<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">rs</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">array</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #ff0000">$row</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #ff0000">$row</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>That&#8217;s a bit of an exaggeration - assignments in a foreach loop is not a good idea and (thankfully) isn&#8217;t very common - but it demonstrates the fundamental problem with common uses of loops - they stop making sense.</p>
<p>What if we could improve that? Consider this example:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$db</span> <span style="color: #b1b100;">as</span> <span style="color: #ff0000">$row</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// ...</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Where $db is an object. That&#8217;s right, iterating over an object. Now, typically when we iterate over an object, we get an array of its public properties. In this case, we can control from within the object $db precisely what we get when we iterate over it, by implementing the Iterator interface.</p>
<p>This can work just fine, as when you iterate over an object, you can probably write a little bit of code within that object so that it knows what you wanted in the previous more complex example. For example, if you&#8217;re running a database query then fetching the resultset, you can instead run the database query then &#8220;fetch&#8221; the entire database object. When you iterate over the database object, it now knows that you really want to iterate over the resultset - and it can do just that.</p>
<p>Here&#8217;s an example of the class that $db might be an instance of:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> MyDatabase implements Iterator
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #ff0000">$data</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">data</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Result 1&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;Result 2&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #000066;">rewind</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000066;">reset</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">data</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #000066;">current</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #ff0000">$var</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">current</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">data</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$var</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #000066;">key</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #ff0000">$var</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">key</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">data</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$var</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #000066;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #ff0000">$var</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">data</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$var</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> valid<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #ff0000">$var</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">current</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">!==</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$var</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>As you can see, it&#8217;s a perfectly normal class, implementing methods with names close to the standard array functions. When your object is iterated over, these Iterator methods will be called where needed. What actually happens inside the methods is up to you &#8212; in this instance, we store the data in an array, $this->data, but it could as well be a complex recordset or XML node tree. As long as calling the appropriate methods performs the action needed, our class can manage its data internally and all we have to do is iterate over it like any other PHP array.</p>
<p>And just for readability, we could always go a step further:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #ff0000">$books</span> <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&amp;</span><span style="color: #ff0000">$db</span><span style="color: #66cc66;">;</span> <span style="color: #808080; font-style: italic;">// $books is now our $db object</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$books</span> <span style="color: #b1b100;">as</span> <span style="color: #ff0000">$book</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">// ...</span>
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Now isn&#8217;t that what you&#8217;d like to see when working with someone else&#8217;s code?</p>
<p>For further reading on object iteration, check out the <a target="_blank" href="http://developertutorials.com/php-manual/language.oop5.iterations.html">manual page on iterating objects</a>. Also take a look the <a target="_blank" href="http://developertutorials.com/php-manual/ref.spl.html">standard PHP library</a> functions.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d150').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d150" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/iterating-php-objects-spl-iterato-150/&amp;title=Iterating+PHP+objects%2C+and+readable+code+too%21" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/iterating-php-objects-spl-iterato-150/&amp;title=Iterating+PHP+objects%2C+and+readable+code+too%21" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/iterating-php-objects-spl-iterato-150/&amp;title=Iterating+PHP+objects%2C+and+readable+code+too%21" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/iterating-php-objects-spl-iterato-150/&amp;title=Iterating+PHP+objects%2C+and+readable+code+too%21" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d150').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/iterating-php-objects-spl-iterato-150/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP array_walk(): Run an array through a function</title>
		<link>http://www.developertutorials.com/blog/php/php-functions/php-array_walk-run-an-array-through-a-function-128/</link>
		<comments>http://www.developertutorials.com/blog/php/php-functions/php-array_walk-run-an-array-through-a-function-128/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 08:41:28 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP Functions]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[php arrays]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/functions/php-array_walk-run-an-array-through-a-function-128/</guid>
		<description><![CDATA[If you&#8217;ve been developing with PHP for a while, you&#8217;ve probably come across this situation in the past:

&#60;?php
foreach ($somearray as &#038;$element) {
    $element = some_function($element);
}

It&#8217;s a common sight: taking an array and running (well, walking) its elements through a particular function. Luckily, PHP provides a simple yet powerful function to overcome this: [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve been developing with PHP for a while, you&#8217;ve probably come across this situation in the past:</p>
<pre>
&lt;?php
foreach ($somearray as &#038;$element) {
    $element = some_function($element);
}
</pre>
<p>It&#8217;s a common sight: taking an array and running (well, walking) its elements through a particular function. Luckily, PHP provides a simple yet powerful function to overcome this: <a href="http://developertutorials.com/php-manual/function.array-walk.html">array_walk()</a>.</p>
<p><strong>Usage</strong><br />
Using array walk is simple. It takes two arguments, an array of data and a callback function to pass the array to. It examines the array and calls the callback function with each element of the array, allowing you to run the entire array through the function without extracting the array yourself. Consider this:</p>
<pre>
&lt;?php
function some_function(&#038;$element, $key) {
    return $element + 1;
}

// This:
foreach ($somearray as $key=>&#038;$element) $element = some_function($element, $key);

// becomes this:
array_walk($somearray, "some_function");
</pre>
<p>It&#8217;s cleaner, faster and more effective. It also gives your callback function more information than you might usually provide. The callback parameter can be any <a href="http://au2.php.net/manual/en/language.pseudo-types.php#language.types.callback"valid callback</a>: &#8220;function_name&#8221;, array(&#8217;Class_name&#8217;, &#8216;method_name&#8217;) or even array($object, &#8216;method_name&#8217;) (where $object can be $this as needed).</p>
<p><strong>Syntax</strong><br />
The syntax is very simple:</p>
<pre>array_walk (array &#038;$array, callback $callback[, mixed $userdata]);</pre>
<p>The first parameter is the array that you want to run through the function. The second is the callback - for a function, class method or object method. The third allows you to pass a third parameter to the callback function from within the current context. This can be anything at all, and along with the array element and its key/index, will be passed directly to the function without modification.</p>
<p>For more details, see <a target="_blank" href="http://developertutorials.com/php-manual/function.array-walk.html">array_walk() in the PHP manual</a>.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d128').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d128" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/php-functions/php-array_walk-run-an-array-through-a-function-128/&amp;title=PHP+array_walk%28%29%3A+Run+an+array+through+a+function" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/php-functions/php-array_walk-run-an-array-through-a-function-128/&amp;title=PHP+array_walk%28%29%3A+Run+an+array+through+a+function" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/php-functions/php-array_walk-run-an-array-through-a-function-128/&amp;title=PHP+array_walk%28%29%3A+Run+an+array+through+a+function" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/php-functions/php-array_walk-run-an-array-through-a-function-128/&amp;title=PHP+array_walk%28%29%3A+Run+an+array+through+a+function" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d128').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/php-functions/php-array_walk-run-an-array-through-a-function-128/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP-friendly web services/APIs for quick mashups</title>
		<link>http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/</link>
		<comments>http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 05:57:39 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[mashups]]></category>

		<category><![CDATA[php tips]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/</guid>
		<description><![CDATA[If you want to build a useful app quickly, you can&#8217;t go past a mashup. Take data from someone else&#8217;s service, come up with a useful way to mix it up and present it to your users in an innovative manner. Even better, as my recent PHP Site Search tutorial showed, you can build a [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to build a useful app quickly, you can&#8217;t go past a mashup. Take data from someone else&#8217;s service, come up with a useful way to mix it up and present it to your users in an innovative manner. Even better, as my recent PHP Site Search tutorial showed, you can build a mashup in just a few lines of code. But how do you find useful web services/APIs, and how do you process the data they provide?</p>
<h3>Finding APIs/web services</h3>
<p>Finding APIs and web services is really quite easy. If you regularly use a web application - for example, I&#8217;ve often used Twitter - check if the application provides an API (Twitter has quite a comprehensive one). Next, if you&#8217;re looking for data on a particular topic, try searching for it. A quick search for &#8220;map api&#8221; returns all kinds of useful results. Finally, if you just want to take a look at the internet&#8217;s available APIs, head to <a href="http://www.programmableweb.com/" target="_blank" rel="external nofollow">Programmable Web</a>; they have by far the most comprehensive database available, and it&#8217;s fully searchable.</p>
<h3>Handling API output</h3>
<p>The easiest way is a really PHP-friendly APIs that provides serialized PHP. You can just fetch the URL with <a href="http://developertutorials.com/php-manual/function.file-get-contents.html" target="_blank">file_get_contents()</a>, and run the output through <a href="http://developertutorials.com/php-manual/function.unserialize.html" target="_blank">unserialize()</a>; in two lines of code, you have your data ready to work with.</p>
<p>However, most APIs won&#8217;t offer serialized PHP output; some might offer JSON, or JavaScript Object Notation, which is somewhat like PHP&#8217;s serialized data (although JSON is integrated in the JavaScript language). Others offer XML gateways, while some even provide SOAP, a (rather complicated) means for computers to talk to each other natively. You really have three options:</p>
<p>1. Interpret the output of the API or web service with a PHP-based parser, such as an XML parser (which you can easily find on phpclasses.org) or a SOAP client (try nusoap).<br />
2. Use PHP sample code provided by the API/web service owner - e.g. <a href="http://code.google.com/apis/checkout/samples/Google_Checkout_Sample_Code_PHP.html" target="_blank">this Google Checkout PHP sample</a>. Some even <a href="http://www.maxmind.com/app/php" target="_blank" rel="external nofollow">provide PECl extensions</a>.<br />
3. Use a third-party library to access the service. For example, people have written PHP classes that allow you to interact with the Flickr API. <a href="http://www.phpclasses.org/browse/class/33.html" target="_blank">PHP Classes.org has hundreds of these</a>, and others are just a web search away.</p>
<h3>Some PHP-friendly APIs</h3>
<p>Of course, if you just want to get started right now and quickly add some functionality to your application, try these:</p>
<ul>
<li><a href="http://recaptcha.net/plugins/php/">reCAPTCHA PHP library</a>: add effective CAPTCHA to your application in pure PHP</a> with reCAPTCHA</li>
<li><a href="http://developer.yahoo.com/php/">Yahoo PHP developer center</a>: Yahoo! provides some very useful search APIs that you can probably use. Also see my <a href="http://developertutorials.com/tutorials/php/php-site-search-made-easy-8-03-30/page1.html" target="_blank">PHP Site Search Made Easy</a> tutorial making use of these APIs.</li>
<li><a href="http://www.flickr.com/services/api/response.php.html" target="_blank">Flickr Services with PHP Response</a></li>
</ul>
<p>Have a look through these APIs and you could be building a mashup quickly in no time.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d104').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d104" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/&amp;title=PHP-friendly+web+services%2FAPIs+for+quick+mashups" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/&amp;title=PHP-friendly+web+services%2FAPIs+for+quick+mashups" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/&amp;title=PHP-friendly+web+services%2FAPIs+for+quick+mashups" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/&amp;title=PHP-friendly+web+services%2FAPIs+for+quick+mashups" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d104').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/php-friendly-web-servicesapis-for-quick-mashups-104/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP 6 now with .net: Visual Studio integration available already</title>
		<link>http://www.developertutorials.com/blog/php/php-6-now-with-net-visual-studio-integration-available-already-101/</link>
		<comments>http://www.developertutorials.com/blog/php/php-6-now-with-net-visual-studio-integration-available-already-101/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 09:47:02 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[php 6]]></category>

		<category><![CDATA[Silverlight]]></category>

		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/php/php-6-now-with-net-visual-studio-integration-available-already-101/</guid>
		<description><![CDATA[Edit: This was partly an April Fool&#8217;s joke, as many PHP scripters would be incredulous at the mere idea of PHP integration with Microsoft products. However, as you might have noticed, much of this post is very much real - besides the compulsory .net with PHP 6, of course. The Phalanger project has made done [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Edit:</strong> This was partly an April Fool&#8217;s joke, as many PHP scripters would be incredulous at the mere idea of PHP integration with Microsoft products. However, as you might have noticed, much of this post is very much real - besides the compulsory .net with PHP 6, of course. The Phalanger project has made done some fantastic work on compiling PHP with .net/Mono, and is definitely worth a look.</p>
<p>When it comes to the enterprise software development market, Microsoft pretty much has it cornered. After all, who else can boast of a complete software ecosystem, fully supported by the company behind one of the world&#8217;s wealthiest men? From Visual Studio to the various certifications, VB being taught in schools and even the wide penetration of the Visual Studio family of development environments, MS has pretty much got it in one. But it&#8217;s .net that seals the deal: the cross-language runtime environment is perfect.</p>
<p><a href="http://www.php-compiler.net/doku.php?id=core%3aphp-in-vs2008" target="_blank">PHP, .net and Silverlight will be integrated out of the box, along with Visual Studio 2008</a>. The project has long been in the works, but our sources have informed us of an impending announcement that PHP 6 will ship with .net. (Our sources are unreliable, but their information is fascinating! - Ashleigh Brilliant.) Versions 1.0, 2.0 or 3.5 of the .net framework will be a part of the basic requirements of PHP 6 as a result. Here&#8217;s a sample:</p>
<p><a href="http://www.developertutorials.com/blog/php/php-6-now-with-net-visual-studio-integration-available-already-101/php-6-with-net-and-silverlight-in-visual-studio/" rel="attachment wp-att-102" title="PHP 6 with .net and Silverlight in Visual Studio"><img src="http://www.developertutorials.com/blog/wp-content/uploads/2008/04/phpdotnetsilverlight.png" width="450" alt="PHP 6 with .net and Silverlight in Visual Studio" /></a></p>
<p>The .net integration was made possible by <a href="http://www.php-compiler.net/doku.php" target="_blank">the Phalanger project</a>, which has been working hard on this for quite a while - with the help of Redmond, of course.</p>
<p>The Visual Studio IDE typically ships as an IDE with a particular language, merging together when additional languages are added. Microsoft has since released Visual Studio 2008 Shell, an IDE with no particular language environment, in which PHP/Phalanger can be added. Debugging of .net and Silverlight is possible thanks to the integration of Visual Studio. Once installed, a new PHP project will be available from within Visual Studio 2008. <a href="http://winbinder.org/" target="_blank">WinBinder</a> now has competition for Windows RAD PHP development:</p>
<p><a href="http://www.developertutorials.com/blog/php/php-6-now-with-net-visual-studio-integration-available-already-101/visual-rad-development-for-php-net-forms-and-controls-with-winforms/" rel="attachment wp-att-103" title="Visual (RAD) development for PHP - .net forms and controls with WinForms"><img src="http://www.developertutorials.com/blog/wp-content/uploads/2008/04/phpdotnetrad.png" width="450" alt="Visual (RAD) development for PHP - .net forms and controls with WinForms" /></a></p>
<p>Sysadmins with Windows servers running applications that conflict with the .net CLR are advised to upgrade to <a href="http://en.wikipedia.org/wiki/INTERCAL" target="_blank" rel="external nofollow">the Intercal interpreter</a> once PHP 5 support is dropped.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d101').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d101" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/php/php-6-now-with-net-visual-studio-integration-available-already-101/&amp;title=PHP+6+now+with+.net%3A+Visual+Studio+integration+available+already" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/php/php-6-now-with-net-visual-studio-integration-available-already-101/&amp;title=PHP+6+now+with+.net%3A+Visual+Studio+integration+available+already" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/php/php-6-now-with-net-visual-studio-integration-available-already-101/&amp;title=PHP+6+now+with+.net%3A+Visual+Studio+integration+available+already" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/php/php-6-now-with-net-visual-studio-integration-available-already-101/&amp;title=PHP+6+now+with+.net%3A+Visual+Studio+integration+available+already" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d101').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/php/php-6-now-with-net-visual-studio-integration-available-already-101/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Open Source Social Networking Server: Built on LAMP!</title>
		<link>http://www.developertutorials.com/blog/web/open-source-social-networking-server-built-on-lamp-99/</link>
		<comments>http://www.developertutorials.com/blog/web/open-source-social-networking-server-built-on-lamp-99/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 12:11:09 +0000</pubDate>
		<dc:creator>Akash Mehta</dc:creator>
		
		<category><![CDATA[Web]]></category>

		<category><![CDATA[LAMP]]></category>

		<category><![CDATA[open source]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.developertutorials.com/blog/web/open-source-social-networking-server-built-on-lamp-99/</guid>
		<description><![CDATA[Social networking just keeps on growing. It seems every major public business wants a Facebook application, corporations are adding social features to their websites, and organisations are bringing social networking into their intranets. Previously, building your own social networking applications involved some serious engineering challenges. Thanks to Ringside Networks, that just got a lot easier, [...]]]></description>
			<content:encoded><![CDATA[<p>Social networking just keeps on growing. It seems every major public business wants a Facebook application, corporations are adding social features to their websites, and organisations are bringing social networking into their intranets. Previously, building your own social networking applications involved some serious engineering challenges. Thanks to <a href="http://www.ringsidenetworks.com/" target="_blanK">Ringside Networks</a>, that just got a lot easier, with an open source (LGPL) social networking server built entirely on LAMP.</p>
<p><span id="more-99"></span></p>
<p>So, what is Ringside, exactly? From a developer perspective, it&#8217;s a social networking application server built on PHP and MySQL, designed to be integrated into your existing applications. If you&#8217;ve already got a web application, just add Ringside to manage the social networking side of things. It&#8217;s thoroughly documented - just check out the seven page <a href="http://wiki.ringsidenetworks.org/display/ringside/Advanced+Developer+Setup" target="_blank">developer setup guide</a> detailing everything you need to setup your LAMP stack and your Eclipse+PDT development environment. You can even <a href="http://wiki.ringsidenetworks.org/display/ringside/Installation+and+Update+with+Pear" target="_blank">install Ringside via PEAR</a>: they&#8217;re serious about their PHP.</p>
<p>But what does Ringside mean for social networking? For a start, it could seriously break apart the market for social networking websites. Facebook application development? Forget it. Sure, there&#8217;s a big audience with Facebook, but OpenSocial will bring users away from specific providers, while Ringside will give them somewhere else to go. Thanks to Ringside, building a custom social networking application is now much easier, and while it still doesn&#8217;t have the simplicity of an online-DIY hosted solution like <a href="http://www.ning.com/" target="_blank">Ning</a>, it will make it a lot easier to integrate social networking.</p>
<p>On a more general scale, this will also help immensely in bringing LAMP closer to the corporate world. Sure, many corporations are already on it, and if LAMP can handle Yahoo!, no challenge is too great. Still, formally-backed proprietary solutions such as Microsoft&#8217;s Windows Server and Small Business Server are highly effective for many areas of a business networ, and with those in place, IIS and ASP.net are the obvious next step. (And there&#8217;s always <a href="http://en.wikipedia.org/wiki/Community_Server" target="_blank" rel="external nofollow">Community Server</a>.) With Ringside, and the ease of building on open source platforms in general, there&#8217;s now a much stronger use case for corporations, and these high-end corporate LAMP jobs will no doubt raise the profile of our section of the industry in general.</p>
<p>So, as a LAMP developer, you now have this proposition before you: do you want to learn about the Facebook API, when you could start reading up on the <a href="http://wiki.ringsidenetworks.org/display/ringside/Home" target="_blank">Ringside manual</a>?</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d99').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d99" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.developertutorials.com/blog/web/open-source-social-networking-server-built-on-lamp-99/&amp;title=Open+Source+Social+Networking+Server%3A+Built+on+LAMP%21" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.developertutorials.com/blog/web/open-source-social-networking-server-built-on-lamp-99/&amp;title=Open+Source+Social+Networking+Server%3A+Built+on+LAMP%21" title="Add to&nbsp;digg"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://www.developertutorials.com/blog/web/open-source-social-networking-server-built-on-lamp-99/&amp;title=Open+Source+Social+Networking+Server%3A+Built+on+LAMP%21" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.developertutorials.com/blog/web/open-source-social-networking-server-built-on-lamp-99/&amp;title=Open+Source+Social+Networking+Server%3A+Built+on+LAMP%21" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.developertutorials.com/blog/wp-content/plugins/social_bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d99').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.developertutorials.com/blog/web/open-source-social-networking-server-built-on-lamp-99/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
