<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>SitePoint &#187; PHP</title>
	<atom:link href="http://www.sitepoint.com/blogs/category/tech/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<pubDate>Sat, 04 Jul 2009 17:39:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ready for PHP &amp; MySQL Week at SitePoint?</title>
		<link>http://www.sitepoint.com/blogs/2009/07/03/ready-for-php-mysql-week-at-sitepoint/</link>
		<comments>http://www.sitepoint.com/blogs/2009/07/03/ready-for-php-mysql-week-at-sitepoint/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 04:35:02 +0000</pubDate>
		<dc:creator>Andrew Tetlaw</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11891</guid>
		<description><![CDATA[To celebrate the release of the new edition of well-loved SitePoint book "Build Your Own Database Driven Web Site Using PHP &#038; MySQL, 4th Edition" — by Kevin Yank, we're publishing a chapter a day next week, beginning Tuesday the 7th of July. Check out what you'll be reading.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sitepoint.com/books/phpmysql4/"><img class="imgright alignright" title="Build Your Own Database Driven Web Site Using PHP &amp; MySQL, 4th Edition" src="http://www.sitepoint.com/images/books/phpmysql4/blocks.jpg" alt="" /></a>To celebrate the release of the new edition of well-loved SitePoint book <em><a href="http://www.sitepoint.com/books/phpmysql4/">Build Your Own Database Driven Web Site Using PHP &amp; MySQL, 4th Edition</a></em> — by Kevin Yank, we&#8217;re publishing a chapter a day next week, beginning Tuesday the 7th of July.</p>
<p>Today, we&#8217;ve published the beginning of the series: <a href="http://www.sitepoint.com/article/php-mysql-tutorial/">the Introduction</a> and directly from the book, <a href="http://www.sitepoint.com/article/php-amp-mysql-1-installation/">Chapter 1: Installation</a>. Over the weekend you can read chapter 1 and make sure your newly installed software is working properly, in readiness for next week&#8217;s chapters. At the end of the week you&#8217;ll have <strong>4 complete chapters from the book and one bonus article</strong>, comprising another book excerpt.</p>
<p>Here&#8217;s what you&#8217;ll be receiving:</p>
<p><strong>Chapter 2: Introducing MySQL</strong></p>
<div id="adz" class="vertical"></div><p>An introduction to databases in general, and the MySQL relational database management system in particular. If you&#8217;ve never worked with a relational database before, you&#8217;ll find this enlightening, whetting your appetite for what’s to come! In the process, you’ll build up a simple database to be used in later chapters.</p>
<p><strong>Chapter 3: Introducing PHP</strong></p>
<p>Here’s where the fun really starts. In this chapter, Kevin will introduce you to the PHP scripting language, which you can use to build dynamic web pages that present up-to-the-moment information to your visitors.</p>
<p><strong>Chapter 4: Publishing MySQL Data on the Web</strong></p>
<p>In this chapter you’ll bring together PHP and MySQL to create some of your first database driven web pages. You’ll explore the basic techniques of using PHP to retrieve information from a database and display it on the Web in real time. Kevin will also show you how to use PHP to create web-based forms for adding new entries to, and modifying existing information in, a MySQL database on the fly.</p>
<p><strong>Bonus: How to Handle File Uploads with PHP</strong><br />
In this bonus excerpt from Chapter 12, you&#8217;ll learn how to accept file uploads from your web site visitors securely and store them.</p>
<p><em><a href="http://www.sitepoint.com/books/phpmysql4/">Build Your Own Database Driven Web Site Using PHP &amp; MySQL, 4th Edition</a></em> is one of the most popular PHP books for beginners, and SitePoint&#8217;s first ever book. This shiny new 4th edition has been completely updated using only best-practice PHP. It&#8217;s essential reading for all budding PHP &amp; MySQL developers. For more information, see the <a href="http://www.sitepoint.com/books/phpmysql4/">book page</a>.</p>
<p>If you prefer to read the Adobe Acrobat PDF version of these first four chapters, you can <a href="http://www.sitepoint.com/books/phpmysql4/samplechapters.php">download the first four chapters FREE</a>.</p>
<script src="http://ads.aws.sitepoint.com/adjs.php?region=136&amp;did=adz&amp;adtype=vertical" type="text/javascript"></script>]]></content:encoded>
			<wfw:commentRss>http://www.sitepoint.com/blogs/2009/07/03/ready-for-php-mysql-week-at-sitepoint/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Learn PHP The Easy Way</title>
		<link>http://www.sitepoint.com/blogs/2009/07/02/learn-php-the-easy-way/</link>
		<comments>http://www.sitepoint.com/blogs/2009/07/02/learn-php-the-easy-way/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 10:48:44 +0000</pubDate>
		<dc:creator>ShayneTilley</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11823</guid>
		<description><![CDATA[With over 40,000 copies sold of the three previous editions, I’m very pleased to announce the latest title hot off the SitePoint production line, <em>Build Your Own Database Driven Web Site Using PHP &#038; MySQL, 4th Edition</em>, by Kevin Yank.]]></description>
			<content:encoded><![CDATA[<p><img class="imgright" src="http://www.sitepoint.com/images/books/phpmysql4/cover.jpg" alt="PHPMYSQL4 Cover" /><br />
With over 40,000 copies sold of the three previous editions, I’m very pleased to announce the latest title hot off the SitePoint production line:</p>
<p><strong><a href="http://www.sitepoint.com/books/phpmysql4/">Build Your Own Database Driven Web Site Using PHP &#038; MySQL (4th Edition)</a></strong> &#8212; by Kevin Yank</p>
<p>One of the most popular PHP books for beginners, this shiny new 4th edition has been completely updated using only best-practice PHP.  </p>
<p>In this book you’ll learn how to:</p>
<div id="adz" class="vertical"></div><ul>
<li>install PHP 5 and MySQL 5 on Windows, Linux, or Mac OS X</li>
<li>gain a thorough understanding of PHP syntax</li>
<li>master database design principles and SQL</li>
<li>build a working content management system</li>
<li>add, edit, and delete web content without using HTML</li>
<li>create an ecommerce shopping cart</li>
<li>utilize sessions and cookies to track site visitors</li>
<li>craft SEO-friendly and memorable URLs</li>
</ul>
<p>And a whole lot more &#8230; </p>
<p>At around 480 pages, this book is an easy read. As you move through the book you’ll quickly notice that it’s written in a clear tutorial format that’s easy to understand, and illustrated with plenty of screenshots and diagrams, providing quick visual cues. If you hate wading through dry, academic-style “how to” texts, this book will be a breath of fresh air to you.</p>
<p>If you’ve never built a database driven web site and you’re looking to go beyond the limitations of a static site, this book will start you off in no time. </p>
<p>And if you have built database driven web sites before, the extensive PHP/MySQL reference guides included will ensure this book remains an extremely handy desk reference.</p>
<p>Check out the <a href="http://www.sitepoint.com/books/phpmysql4/samplechapters.php">free sample chapters</a> or <a href="https://sitepoint.com/bookstore/go/157">order a copy today</a>.</p>
<script src="http://ads.aws.sitepoint.com/adjs.php?region=136&amp;did=adz&amp;adtype=vertical" type="text/javascript"></script>]]></content:encoded>
			<wfw:commentRss>http://www.sitepoint.com/blogs/2009/07/02/learn-php-the-easy-way/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Get a Free iPhone: Help SitePoint Recruit a PHP Developer</title>
		<link>http://www.sitepoint.com/blogs/2009/07/02/get-a-free-iphone-help-sitepoint-recruit-a-php-developer/</link>
		<comments>http://www.sitepoint.com/blogs/2009/07/02/get-a-free-iphone-help-sitepoint-recruit-a-php-developer/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 03:23:09 +0000</pubDate>
		<dc:creator>Kevin Yank</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11845</guid>
		<description><![CDATA[SitePoint is looking for two experienced PHP developers (one with a sysadmin twist) to join the team here at SitePoint HQ in Melbourne, Australia. Help us find the right person for either of these positions, and we’ll buy you a shiny, new iPhone 3GS!]]></description>
			<content:encoded><![CDATA[<p><img src="http://i2.sitepoint.com/images/sitepointlogo150.png" alt="" class="imgright" /></p>
<p><strong>SitePoint is looking for two experienced PHP developers (one with a sysadmin twist) to join the team here at SitePoint HQ in Melbourne, Australia. Help us find the right person for either of these positions, and we’ll buy you a shiny, new iPhone 3GS!</strong></p>
<p>Know someone with “mad PHP skillz” who either lives in Melbourne or would move here for the opportunity to work on one of the Web’s major destination sites for web developers and designers? Drop me an email with the details at <strong>kevin(at)sitepoint.com</strong>.</p>
<p>Of course, if you would just like to apply for the position yourself, the complete position descriptions are in our <a href="http://www.sitepoint.com/about/jobs/">jobs section</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sitepoint.com/blogs/2009/07/02/get-a-free-iphone-help-sitepoint-recruit-a-php-developer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Note on Google&#8217;s So-called Best Practices</title>
		<link>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/</link>
		<comments>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 22:49:07 +0000</pubDate>
		<dc:creator>Troels Knak-Nielsen</dc:creator>
		
		<category><![CDATA[PHP]]></category>
<category>google</category><category>performance</category><category>php</category><category>profiling</category>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=11556</guid>
		<description><![CDATA[The advice for PHP developers in Google's recent "make the web faster" campaign are plain wrong. Troels tackles some of the tips and provides some words of wisdom on how to really optimise your site's performance.]]></description>
			<content:encoded><![CDATA[<p>Earlier this week, Google launched a campaign to <a href="http://code.google.com/speed/">make the web faster</a>. It appears to be a call for improving the quality of web sites in general, but with a focus on performance.</p>
<p>The project includes an article on <a href="http://code.google.com/speed/articles/optimizing-php.html">&#8220;PHP performance tips&#8221;</a>, which is bordering on being ridiculous. There are of course lots of blog posts with similar nonsense around the web, but since this is being endorsed by Google, it&#8217;s fair to assume that people might take it at face value. That&#8217;s unfortunate, as <strong>almost none of it is true.</strong> The PHP Team responded back with <a href="http://groups.google.com/group/make-the-web-faster/browse_thread/thread/ddfbe82dd80408cc">this message</a>, wherein they refute the unfounded nonsense.</p>
<p>What&#8217;s more troubling however, is the whole approach to performance optimisation as a matter of &#8220;knowing the secret handshake&#8221;. Optimisation is far more complex than that, and spending time on these &#8220;optimisation tricks&#8221; are rarely worthwhile and <a href="http://en.wikipedia.org/wiki/Optimization_(computer_science)#cite_note-0">might often lead to unmaintainable code, if applied too early</a>. It&#8217;s a fine line, because there <em>are</em> of course certain things that you shouldn&#8217;t do (such as hit the database within a tight loop, if you can send one query instead), but there are likewise lots of things that are a complete and utter waste of every body&#8217;s time. It&#8217;s a pity that this article failed to keep those two issues separate.</p>
<p>Performance optimisation is not magic. The real way to deal with it, is to measure and analyse. It is almost impossible &#8212; even for a highly skilled programmer &#8212; to anticipate exactly where there might be bottlenecks in a program. Using a profiler gives you real numbers to relate to, rather than wild guesses and superstition.</p>
<div id="adz" class="horizontal"></div><p>For PHP scripts, there is the freely available <a href="http://www.xdebug.org/docs/profiler">Xdebug extension</a>, which provides detailed information on both memory usage and execution time on a per-function basis. It&#8217;s easy to install and with the simple <a href="http://code.google.com/p/webgrind/">WebGrind</a> as a front-end, you&#8217;ll be up and running in no time.</p>
<script src="http://ads.aws.sitepoint.com/adjs.php?region=137&amp;did=adz&amp;adtype=horizontal" type="text/javascript"></script>]]></content:encoded>
			<wfw:commentRss>http://www.sitepoint.com/blogs/2009/06/26/a-note-on-googles-so-called-best-practises/feed/</wfw:commentRss>
		</item>
		<item>
		<title>16 PHP Frameworks To Consider For Your Next Project</title>
		<link>http://www.sitepoint.com/blogs/2009/06/09/16-php-frameworks/</link>
		<comments>http://www.sitepoint.com/blogs/2009/06/09/16-php-frameworks/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 13:17:50 +0000</pubDate>
		<dc:creator>Sean Aune</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=10329</guid>
		<description><![CDATA[Why spend valuable time coding everything by hand? Using a PHP framework is a great way to save time and effort on your next project. Sean highlights 16 frameworks for you to choose from.]]></description>
			<content:encoded><![CDATA[<p>Why spend valuable time coding everything by hand? Using a framework is a great way to save time and effort on your next project—you&#8217;ll have a firm foundation to build upon, there will be pre-built modules to perform tedious coding tasks, and if you&#8217;re a learner, it&#8217;s a great way to learn about good coding practice. PHP&#8217;s massive popularity means that developers have a wide variety of frameworks to choose from. We&#8217;re sure you can find one amongst these 16 to meet your needs.</p>
<p><strong><a href="http://www.agavi.org/" target="_blank">Agavi</a></strong>: This PHP 5-based framework started off as a fork of the popular Mojavi project.  While it can be used as a web site construction kit, its primary focus is on building fully-fledged applications.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/agavi.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/agavis.png" alt="agavi" title="agavi" width="300" height="146" class="imgcenter" /></a></p>
<p><a href="http://www.akelos.org/" target="_blank"><strong>Akelos</strong></a>: Akelos is a PHP port of a Ruby on Rails framework for building web applications.  It avoids complex configurations, making it ideal for use on simpler web servers. There&#8217;s a healthy community around this one!</p>
<div id="adz" class="horizontal"></div><p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/akelos.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/akelos.png" alt="akelos" title="akeloss" width="300" height="140" class="imgcenter" /></a></p>
<p><strong><a href="http://www.cakephp.org/" target="_blank">CakePHP</a></strong>: The very well-known CakePHP is easy for coders of all skill levels to use. It&#8217;s based on the same principles that guide Ruby on Rails, and its heavy focus on rapid deployment methods make it a great choice for developers who are squeezed for time (see SitePoint&#8217;s <a href="http://www.sitepoint.com/article/application-development-cakephp/">beginner&#8217;s CakePHP tutorial</a> to get started).</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/cake.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/cakes.png" alt="cake" title="cake" width="300" height="121" class="imgcenter" /></a></p>
<p><strong><a href="http://www.codeigniter.com/" target="_blank">CodeIgniter</a></strong>: EllisLab&#8217;s CodeIgniter has won wide praise for its small footprint and speed, and has become a favorite amongst many developers. There&#8217;s extensive documentation and a large community of users to help you out.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/codeigniter.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/codeigniters.png" alt="codeigniter" title="codeigniter" width="300" height="177" class="imgcenter" /></a></p>
<p><a href="http://ez.no/ezcomponents" target="_blank"><strong>eZ Components</strong></a>: OK, so we&#8217;re stretching the definition of framework here. eZ Components, as the name suggests, is a library of individual components for common tasks. If you&#8217;re familiar with the ezPublish CMS, you might have seen some of these components before!</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/ezcomponents.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/ezcomponentss.png" alt="ezcomponents" title="ezcomponents" width="300" height="170" class="imgcenter" /></a></p>
<p><a href="http://www.phpfuse.net/" target="_blank"><strong>Fuse</strong></a>: Fuse is based on Ruby on Rails and CakePHP, but has had many features added by the development team to make the most stable platform they could. There are frequent updates—development on version 2.0 is underway!</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/fuse.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/fuses.png" alt="fuse" title="fuse" width="300" height="140" class="imgcenter" /></a></p>
<p><strong><a href="http://www.horde.org/horde/" target="_blank">Horde</a></strong>: This mainstay of the PHP framework world grew from the Horde webmail and groupware suite.  If you&#8217;re a developer who speaks a language other than English, you may be interested in the fact that the framework is designed specifically to be localization-friendly.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/horde.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/hordes.png" alt="horde" title="horde" width="300" height="140" class="imgcenter" /></a></p>
<p><strong><a href="http://kohanaphp.com/" target="_blank">Kohana</a></strong>: Kohana, originally based on CodeIgniter, puts its focus on being small, fast, and secure.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/kohana.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/kohanas.png" alt="kohana" title="kohana" width="300" height="168" class="imgcenter" /></a></p>
<p><strong><a href="http://www.phpontrax.com/" target="_blank">PHP on TRAX</a></strong>: A PHP framework based on Ruby on Rails (Get that name? Nudge nudge!) that is focused on building database-backed web applications based on the MVC structure.  You&#8217;ll find a healthy developer community, demos, and even screencasts.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/phpontrax.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/phpontraxs.png" alt="php on trax" title="php on trax" width="300" height="162" class="imgcenter" /></a></p>
<p><strong><a href="http://www.phpopenbiz.org/jim/" target="_blank">PHPOpenBiz</a></strong>: This PHP framework claims to have business development in mind, though we&#8217;re not sure how it is that other frameworks aren&#8217;t suitable for that purpose.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/phpopenbiz.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/phpopenbizs.png" alt="phpopenbiz" title="phpopenbiz" width="300" height="135" class="imgcenter" /></a></p>
<p><strong><a href="http://qcu.be/" target="_blank">Qcubed</a></strong>: Qcubed is a fork of the Qcodo framework which had remained dormant for some time. It&#8217;s back, and its focus is on rapid prototyping. You&#8217;ll find fun tutorials on the site, and an enthusiastic new set of developers.</p>
<p><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/picture-103-300x160.png" alt="QCubed" title="QCubed" width="300" height="160" class="imgcenter" /></p>
<p><strong><a href="http://www.seagullproject.org/" target="_blank">Seagull</a></strong>:  This well-established PHP framework is easy to pick up for developers of any skill level.  If you&#8217;re a beginner, you&#8217;ll find many pre-built apps to examine and extend, and there&#8217;s something for experts too—cash bounties are offered for improvements to the code.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/seagull.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/seagulls.png" alt="seagull" title="seagull" width="300" height="132" class="imgcenter" /></a></p>
<p><a href="http://www.symfony-project.com/" target="_blank"><strong>Symfony</strong></a>: The ever-popular Symfony is directed more at enterprise application development, and it may have some trouble with shared hosting solutions as they lack a PHP accelerator.  This is definitely more of an advanced developer framework than some of the others out there.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/symfony.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/symfonys.png" alt="symfony" title="symfony" width="300" height="120" class="imgcenter" /></a></p>
<p><strong><a href="http://www.phpwact.org/" target="_blank">WACT</a></strong>: Short for Web Application Component Toolkit, WACT emphasizes the need for frequent code refactoring, unit testing, and good security.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/wact.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/wacts.png" alt="wact" title="wact" width="300" height="127" class="imgcenter" /></a></p>
<p><strong><a href="http://framework.zend.com/" target="_blank">Zend</a></strong>: Zend is focused on Web 2.0 style applications. It&#8217;s simple to use APIs from sites such as Google, Flickr, Amazon and so on (check out the SitePoint <a href="http://www.sitepoint.com/article/mash-up-music-zend-framework/">Zend tutorial</a> for more on this).  With a massive user base, you&#8217;re sure to find plenty of support and advice around the Web.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/zend.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/zends.png" alt="zend" title="zend" width="300" height="140" class="imgcenter" /></a></p>
<p><strong><a href="http://zoopframework.com/" target="_blank">ZooP</a></strong>: A mature PHP framework for beginners and advanced users alike, ZooP focuses on being lightweight and easy to learn.  Features include easy use of PEAR modules, the prototype Ajax framework and stacks of documentation.</p>
<p><a href="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/zoop.png"><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/06/zoops.png" alt="zoop" title="zoop" width="300" height="140" class="imgcenter" /></a></p>
<p>Of course there are many more frameworks out there—users of our <a href="http://www.sitepoint.com/forums/forumdisplay.php?f=147">PHP Application Design Forum</a> drop by every day with discussions of what they&#8217;re working on. What&#8217;s your favorite PHP framework and why?</p>
<script src="http://ads.aws.sitepoint.com/adjs.php?region=137&amp;did=adz&amp;adtype=horizontal" type="text/javascript"></script>]]></content:encoded>
			<wfw:commentRss>http://www.sitepoint.com/blogs/2009/06/09/16-php-frameworks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Introducing Bucket: A Minimal Dependency Injection Container for PHP</title>
		<link>http://www.sitepoint.com/blogs/2009/05/11/bucket-is-a-minimal-dependency-injection-container-for-php/</link>
		<comments>http://www.sitepoint.com/blogs/2009/05/11/bucket-is-a-minimal-dependency-injection-container-for-php/#comments</comments>
		<pubDate>Sun, 10 May 2009 22:25:35 +0000</pubDate>
		<dc:creator>Troels Knak-Nielsen</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=9286</guid>
		<description><![CDATA[Troels got fed up with the lack of a decent Dependency Injection container for PHP, so he did what any diligent programmer would do ... he built his own. Check out Bucket, released today as an open source package.]]></description>
			<content:encoded><![CDATA[<p>I got fed up with the lack of a decent DI-container for PHP, so today I created <a href="http://github.com/troelskn/bucket/tree/master">Bucket</a>. To be clear, what I think is wrong with the currently available containers (at least that I&#8217;m aware of) is that they either are unstable, abandoned, require a lot of up-front configuration in external XML-files, or are tightly integrated into some full-stack framework. I had my hopes up for <a href="http://phemto.sourceforge.net/">Phemto</a> for a while, but it seems that progress has stalled.</p>
<p>Bucket doesn&#8217;t do much, but that is actually the intention. It means that it is feature-complete and probably bug free. And unlike <a href="http://github.com/fabpot/twittee/tree/master">Twittee</a>, it is actually useful as-is.</p>
<p>Bucket is mostly a wrap-up of the code I described a bout a year back in <a href="http://www.sitepoint.com/blogs/2008/02/04/dealing-with-dependencies/">Dealing with Dependencies</a>. It adds a few additional features out-of-the-box. Notably:</p>
<p><em>Default factory uses reflection/typehints to determine dependencies</em>. So you can go:</p>
<div id="adz" class="horizontal"></div><pre><code>class Foo {
}
class Bar {
  function __construct(Foo $foo) {}
}
$container = new bucket_Container();
$container-&gt;get('Bar');
</code></pre>
<p>And with interfaces:</p>
<pre><code>interface Zap {
}
class Foo implements Zap {
}
class Bar {
  function __construct(Zap $zap) {}
}
$container = new bucket_Container();
$container-&gt;registerImplementation('Zap', 'Foo');
$container-&gt;get('Bar');
</code></pre>
<p><em>You can use callbacks for factories</em>. Not that useful right now, but when PHP 5.3 (hopefully very soon) sees the light of day, you can use:</p>
<pre><code>$bucket = new bucket_Container(
  array(
    'pdo' =&gt; function($container) {
      return new PDO("mysql:host=localhost;dbname=addressbook", "root", "secret");
    }
  )
);
</code></pre>
<p>You can also use a class based factory. This can be combined with callbacks, for overriding methods. Eg. if you create a callback, it takes precedence over the class method. Until 5.3, you&#8217;d probably want to write factories as class methods:</p>
<pre><code>class MyFactory {
  function new_pdo($container) {
    return new PDO("mysql:host=localhost;dbname=addressbook", "root", "secret");
  }
}
$bucket = new bucket_Container(new MyFactory());
</code></pre>
<p><em>Support for child scopes</em>. Means that you can create a local container that doesn&#8217;t leak state to its parent. Probably not the most important feature for standard web applications, but a nice feature for longer running scripts. Usage is:</p>
<pre><code>$container = new bucket_Container();
$scope = $container-&gt;makeChildContainer();
</code></pre>
<p>It&#8217;s just 153 lines of code, with no external requirements, so go on and grab your copy at: <a href="http://github.com/troelskn/bucket/tree/master">http://github.com/troelskn/bucket/tree/master</a></p>
<script src="http://ads.aws.sitepoint.com/adjs.php?region=137&amp;did=adz&amp;adtype=horizontal" type="text/javascript"></script>]]></content:encoded>
			<wfw:commentRss>http://www.sitepoint.com/blogs/2009/05/11/bucket-is-a-minimal-dependency-injection-container-for-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Interactive CLI password prompt in PHP</title>
		<link>http://www.sitepoint.com/blogs/2009/05/01/interactive-cli-password-prompt-in-php/</link>
		<comments>http://www.sitepoint.com/blogs/2009/05/01/interactive-cli-password-prompt-in-php/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 21:08:10 +0000</pubDate>
		<dc:creator>Troels Knak-Nielsen</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=8737</guid>
		<description><![CDATA[Just a quick tip, since I spent a good hour figuring this out recently. PHP has no native way of doing an interactive password prompt, when running as CLI. You can however use bash for the task. Of course this means that it won&#8217;t work on Windows, but you should be fine on most anything [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick tip, since I spent a good hour figuring this out recently. PHP has no native way of doing an interactive password prompt, when running as CLI. You can however use bash for the task. <del datetime="2009-05-01T09:49:45+00:00">Of course this means that it won&#8217;t work on Windows, but you should be fine on most anything else.</del> Edit: Using Windows Scripting Host, it&#8217;s possible to pop a prompt up for the user to type in. I&#8217;ve extended the example to use this technique for Windows based systems.</p>
<pre><code>
/**
 * Interactively prompts for input without echoing to the terminal.
 * Requires a bash shell or Windows and won't work with
 * safe_mode settings (Uses `shell_exec`)
 */
function prompt_silent($prompt = "Enter Password:") {
  if (preg_match('/^win/i', PHP_OS)) {
    $vbscript = sys_get_temp_dir() . 'prompt_password.vbs';
    file_put_contents(
      $vbscript, 'wscript.echo(InputBox("'
      . addslashes($prompt)
      . '", "", "password here"))');
    $command = "cscript //nologo " . escapeshellarg($vbscript);
    $password = rtrim(shell_exec($command));
    unlink($vbscript);
    return $password;
  } else {
    $command = "/usr/bin/env bash -c 'echo OK'";
    if (rtrim(shell_exec($command)) !== 'OK') {
      trigger_error("Can't invoke bash");
      return;
    }
    $command = "/usr/bin/env bash -c 'read -s -p \""
      . addslashes($prompt)
      . "\" mypassword &amp;&amp; echo \$mypassword'";
    $password = rtrim(shell_exec($command));
    echo "\n";
    return $password;
  }
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sitepoint.com/blogs/2009/05/01/interactive-cli-password-prompt-in-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Free PHP Webinar: How to Increase Performance with Caching</title>
		<link>http://www.sitepoint.com/blogs/2009/04/21/free-php-webinar/</link>
		<comments>http://www.sitepoint.com/blogs/2009/04/21/free-php-webinar/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 09:01:07 +0000</pubDate>
		<dc:creator>Craig Buckler</dc:creator>
		
		<category><![CDATA[PHP]]></category>
<category>php</category><category>zend</category>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=8269</guid>
		<description><![CDATA[Zend are running a free webinar today, with a live demonstration showing how to improve the performance of your PHP applications using Zend Server caching.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/04/051-php-webinar.png" alt="PHP caching webinar" title="PHP caching webinar" width="260" height="260" class="imgright" />Zend are holding a free webinar on Wednesday 22 April from San Francisco (9:00am PDT, 4:00pm UTC/GMT). The event is led by Shahar Evron and titled <em>&#8220;How to increase application performance using caching&#8221;</em>. Shahar will give a one-hour live demonstration showing the steps required to optimize and boost the performance of your PHP applications using Zend Server.</p>
<p>The company has also released Zend Server Community Edition, a free web application server that is easy to install and use. It is recommended for developers running PHP in a production environment and downloads are available for Windows, Mac and Linux. The package includes:</p>
<ul>
<li>Apache 2.2 web server</li>
<li>PHP</li>
<li>Zend Optimizer+ (opcode caching and optimization)</li>
<li>Zend Cache (data and output caching)</li>
<li>Zend Guard Loader (encoding PHP)</li>
<li>Zend Framework (PHP libraries)</li>
<li>Zend Debugger</li>
<li>Java Server (Java PHP extension)</li>
<li>Java Bridge (integration of Java libraries in PHP)</li>
<li>Oracle Instant database client</li>
<li>IBM DB2 RTCL database client</li>
<li>MySQL database</li>
<li>phpMyAdmin (MySQL management tool)</li>
</ul>
<p>Links:</p>
<div id="adz" class="horizontal"></div><ul>
<li><a href="http://www.zend.com/en/company/news/event/webinar-how-to-increase-application-performance-using-caching">Register for the Zend PHP Caching Webinar</a></li>
<li><a href="http://www.zend.com/en/products/server/downloads-all?zsl=p1">Download Zend Server Community Edition</a></li>
</ul>
<p>See also:</p>
<ul>
<li><a href="http://www.sitepoint.com/blogs/2009/04/07/how-to-install-apache-on-windows/">How to Install Apache Web Server on Windows</a></li>
<li><a href="http://www.sitepoint.com/blogs/2009/04/13/how-to-install-php-on-windows/">How to Install PHP on Windows</a></li>
<li><a href="http://www.sitepoint.com/blogs/2009/03/24/how-to-install-mysql/">How to Install MySQL</a></li>
<li><a href="http://www.sitepoint.com/blogs/2009/03/12/mysql-foreign-keys-quicker-database-development/">How to Use MySQL Foreign Keys for Quicker Database Development</a></li>
</ul>
<p>Did you attend the Zend webinar? Was it any good? Did you learn anything new about PHP?</p>
<script src="http://ads.aws.sitepoint.com/adjs.php?region=137&amp;did=adz&amp;adtype=horizontal" type="text/javascript"></script>]]></content:encoded>
			<wfw:commentRss>http://www.sitepoint.com/blogs/2009/04/21/free-php-webinar/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to Install PHP on Windows</title>
		<link>http://www.sitepoint.com/blogs/2009/04/13/how-to-install-php-on-windows/</link>
		<comments>http://www.sitepoint.com/blogs/2009/04/13/how-to-install-php-on-windows/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 09:03:58 +0000</pubDate>
		<dc:creator>Craig Buckler</dc:creator>
		
		<category><![CDATA[PHP]]></category>
<category>apache</category><category>install</category><category>mysql</category><category>php</category><category>windows</category>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=7958</guid>
		<description><![CDATA[In his final installation tutorial, Craig provides a step-by-step guide to installing PHP5 as an Apache module in your Windows development environment.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/04/041-installing-php.jpg" alt="Install PHP" title="Install PHP" width="260" height="260" class="imgright" />Hopefully, you now have a working <a href="http://www.sitepoint.com/blogs/2009/04/07/how-to-install-apache-on-windows">local installation of Apache on your Windows PC</a>. In this article we will install PHP 5 as an Apache 2.2 module.</p>
<h2>Why PHP?</h2>
<p>PHP remains the most widespread and popular server-side programming language on the web. It is installed by most web hosts, has a simple learning curve, close ties with the MySQL database, and an excellent collection of libraries to cut your development time. PHP may not be perfect, but it should certainly be considered for your next web application. Both Yahoo and Facebook use it with great success.</p>
<h2>Why Install PHP Locally?</h2>
<div id="adz" class="vertical"></div><p>Installing PHP on your development PC allows you to safely create and test a web application without affecting the data or systems on your live website. This article describes PHP installation as a module within the Windows version of Apache 2.2. Mac and Linux users will probably have it installed already.</p>
<h2>All-in-One packages</h2>
<p>There are some excellent all-in-one Windows distributions that contain Apache, PHP, MySQL and other applications in a single installation file, e.g. <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a> (including a <a href="http://www.apachefriends.org/en/xampp-macosx.html">Mac version</a>), <a href="http://www.wampserver.com/en/">WampServer</a> and <a href="http://www.devside.net/server/webdeveloper">Web.Developer</a>. There is nothing wrong with using these packages, although manually installing Apache and PHP will help you learn more about the system and its configuration options.</p>
<h2>The PHP Installer</h2>
<p>Although an installer is available from <a href="http://www.php.net/downloads.php">php.net</a>, I would recommend the manual installation if you already have a web server configured and running.</p>
<h2>Manual Installation</h2>
<p>Manual installation offers several benefits:</p>
<ul>
<li>backing up, reinstalling, or moving the web server can be achieved in seconds (see <a href="http://www.sitepoint.com/blogs/2009/03/03/8-tips-for-surviving-pc-failure/">8 Tips for Surviving PC Failure</a>) and</li>
<li>you have more control over PHP and Apache configuration.</li>
</ul>
<p><strong>Step 1: download the files</strong><br />
Download the latest PHP 5 ZIP package from <a href="http://www.php.net/downloads.php">www.php.net/downloads.php</a></p>
<p>As always, virus scan the file and check its MD5 checksum using a tool such as <a href="http://www.slavasoft.com/fsum/">fsum</a>.</p>
<p><strong>Step 2: extract the files</strong><br />
We will install the PHP files to C:\php, so create that folder and extract the contents of the ZIP file into it.</p>
<p>PHP can be installed anywhere on your system, but you will need to change the paths referenced in the following steps.</p>
<p><strong>Step 3: configure php.ini</strong><br />
Copy C:\php\php.ini-recommended to C:\php\php.ini. There are several lines you will need to change in a text editor (use search to find the current setting).</p>
<p>Define the extension directory:</p>
<pre><code class="ini">extension_dir = "C:\php\ext"</code></pre>
<p>Enable extensions. This will depend on the libraries you want to use, but the following extensions should be suitable for the majority of applications (remove the semi-colon comment):</p>
<pre><code class="ini">
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo.dll
extension=php_pdo_mysql.dll
extension=php_xmlrpc.dll
</code></pre>
<p>If you want to send emails using the PHP <code>mail()</code> function, enter the details of an SMTP server (your ISP&#8217;s server should be suitable):</p>
<pre><code class="ini">
[mail function]
; For Win32 only.
SMTP = mail.myisp.com
smtp_port = 25

; For Win32 only.
sendmail_from = my@emailaddress.com
</code></pre>
<p><strong>Step 4: add C:\php to the path environment variable</strong><br />
To ensure Windows can find PHP, you need to change the path environment variable. From the Control Panel, choose System, (then &#8220;Advanced system settings&#8221; in Vista), select the &#8220;Advanced&#8221; tab, and click the &#8220;Environment Variables&#8221; button. </p>
<p>Scroll down the System variables list and click on &#8220;Path&#8221; followed by the &#8220;Edit&#8221; button. Enter &#8220;<strong>;C:\php</strong>&#8221; to the end of the Variable value line (remember the semi-colon). </p>
<p><img src="http://www.sitepoint.com/blogs/wp-content/uploads/2009/04/041-installing-php.png" alt="PHP path environment variable" title="PHP path environment variable" width="439" height="520" class="imgcenter fullsize" /></p>
<p>Now OK your way out. You might need to reboot at this stage.</p>
<p><strong>Step 5: configure PHP as an Apache module</strong><br />
Ensure Apache is not running (use &#8220;net stop Apache2.2&#8243; from the command line) and open its \conf\httpd.conf configuration file in an editor. The following lines should be changed:</p>
<p>Line 239, add index.php as a default file name:</p>
<pre><code class="ini">
DirectoryIndex index.php index.html
</code></pre>
<p>At the bottom of the file, add the following lines (change the PHP file locations if necessary):</p>
<pre><code class="ini">
# PHP5 module
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"
</code></pre>
<p>Save the configuration file and test it from the command line (Start &gt; Run &gt; cmd):</p>
<pre><code class="dos">
cd \Apache2\bin 
httpd -t
</code></pre>
<p><strong>Step 6: test a PHP file</strong><br />
Create a file named index.php in Apache&#8217;s web page root (either htdocs or D:\WebPages) and add this code:</p>
<pre><code class="php">
&lt;?php phpinfo(); ?&gt;
</code></pre>
<p>Ensure Apache has started successfully, open a web browser and enter the address <strong>http://localhost/</strong>. If all goes well, a &#8220;PHP version&#8221; page should appear showing all the configuration settings.</p>
<p>See also:</p>
<ul>
<li><a href="http://www.sitepoint.com/blogs/2009/04/07/how-to-install-apache-on-windows/">How to Install Apache</a></li>
<li><a href="http://www.sitepoint.com/blogs/2009/03/24/how-to-install-mysql/">How to Install MySQL</a></li>
<li><a href="http://www.sitepoint.com/blogs/2009/03/25/mysql-myisam-table-pros-con/">MySQL: the Pros and Cons of MyISAM Tables</a></li>
<li><a href="http://www.sitepoint.com/blogs/2009/03/26/mysql-innodb-table-pros-cons/">MySQL: the Pros and Cons of InnoDB Tables</a></li>
<li><a href="http://www.sitepoint.com/blogs/2009/03/12/mysql-foreign-keys-quicker-database-development/">How to Use MySQL Foreign Keys for Quicker Database Development</a></li>
</ul>
<p>Best of luck!</p>
<script src="http://ads.aws.sitepoint.com/adjs.php?region=136&amp;did=adz&amp;adtype=vertical" type="text/javascript"></script>]]></content:encoded>
			<wfw:commentRss>http://www.sitepoint.com/blogs/2009/04/13/how-to-install-php-on-windows/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Build a Buzzword Bingo Card in PHP</title>
		<link>http://www.sitepoint.com/blogs/2009/03/03/build-a-buzzword-bingo-card-in-php/</link>
		<comments>http://www.sitepoint.com/blogs/2009/03/03/build-a-buzzword-bingo-card-in-php/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 06:09:12 +0000</pubDate>
		<dc:creator>raena</dc:creator>
		
		<category><![CDATA[PHP]]></category>
<category>JavaScript</category><category>news</category><category>PHP</category><category>web</category>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=6699</guid>
		<description><![CDATA[Bored in meetings? Worry no longer. Raena demonstrates how to ease the pain of meetings by creating your own buzzword bingo game using a scrap of beginner PHP. ]]></description>
			<content:encoded><![CDATA[<p>
  <strong>In the past, I&#8217;ve done a fair bit of work with government departments. Here are three things I learned from that experience: </strong>
</p>
<ol>
<li>
    government workers love meetings
  </li>
<li>
    government workers also love jargon
  </li>
<li>
    when you combine meetings and jargon, you have excellent conditions for a quick game of Buzzword Bingo*
  </li>
</ol>
<p>
  If you&#8217;ve yet to play Buzzword Bingo, you&#8217;re missing out on great fun! It&#8217;s a game in which you collect buzzwords, clich&#233;s, and weasel words, then arrange them in a grid and check them off as you hear them during a particularly wordy meeting. When you&#8217;ve checked off a row, column, or diagonal line &#8212; bingo!
</p>
<p>
  With just a little bit of beginner PHP and a good collection of jargon words, you can make your own buzzword bingo card that&#8217;s randomly generated every time you load the page. Let&#8217;s take a look.
</p>
<p>
  (*Buzzword Bingo has a <em>less than worksafe</em> name too, but because we want this newsletter to pass by unimpeded by any cursing filters, I can&#8217;t repeat it here.)
</p>
<h2>
  Step 1: Create a Function Shell<br />
</h2>
<p>
  We&#8217;ll be creating a function called <code>Bingo</code> to generate a random buzzword bingo card, which we can then include within a document. Let&#8217;s start out by creating a document shell with the <code>Bingo</code> function inside (I&#8217;ve called mine <code>bingo.php)</code>:
</p>
<pre><code>&lt;?php
  function Bingo() {

  }
?&gt;</code></pre>
<h2>
  Step 2: Compile Some Buzzwords<br />
</h2>
<p>
  Grab a list of the jargon words or phrases you&#8217;d like to see in your bingo cards. You&#8217;ll need at least 25 to fill a bingo card, so be sure you have a good collection. I&#8217;ve just spent an amusing few minutes strolling around <a href="http://www.weaselwords.com.au/">Weasel Words</a>, a site devoted to collecting some horrible examples of managerial speak, and I&#8217;ve plucked a bagful of my favorites.
</p>
<p>
  Let&#8217;s pop these in an array inside our PHP function:
</p>
<pre><code>$buzzwords = array(
  &quot;leverage&quot;,
  &quot;synergy&quot;,
  &quot;stakeholder&quot;,
  &quot;touch-points&quot;,
  &quot;knowledge initiatives&quot;,
  &quot;cross-organizational collaboration&quot;,
  &quot;strategic planning&quot;,
  &quot;dynamics&quot;,
  &quot;catalyst&quot;,
  &quot;values-driven&quot;,
  &quot;evangelize&quot;,
  &quot;incentivize&quot;,
  &quot;loop back&quot;,
  &quot;let's take this offline&quot;,
  &quot;360 degree thinking&quot;,
  &quot;in the pipeline&quot;,
  &quot;actioning&quot;,
  &quot;paradigm&quot;,
  &quot;2.0&quot;,
  &quot;going forward&quot;,
  &quot;game plan&quot;,
  &quot;the end of the day&quot;,
  &quot;thought leading&quot;,
  &quot;on board&quot;,
  &quot;monetize&quot;
  );</code></pre>
<h2>
  Step 3: Do the Shuffle<br />
</h2>
<p>
  We want to make sure our card has a random arrangement of buzzwords, so we&#8217;ll use <a href="http://php.net/shuffle">PHP&#8217;s <code>shuffle</code> function</a> to jumble up the items in the array:
</p>
<pre><code>shuffle($buzzwords);</code></pre>
<h2>
  Step 4: Prepare a Table<br />
</h2>
<p>
  Bingo is all about filling up rows or columns in a grid, so we&#8217;ll use a table to arrange the items.
</p>
<p>
  Let&#8217;s create a new variable called <code>$bingocard</code> and start preparing the table markup. You can see I&#8217;ve left a gap in the middle &#8212; this is where we&#8217;ll later put the code that creates the cells and rows.
</p>
<pre><code>$bingocard = &quot;&lt;table id='bingo'
summary='A random selection of 25 buzzwords
arranged in a bingo card'&gt;&quot;;
$bingocard .= &quot;&lt;thead&gt;&lt;tr&gt;&quot;;
$bingocard .= &quot;&lt;th&gt;B&lt;/th&gt;
      &lt;th&gt;I&lt;/th&gt;&lt;th&gt;N&lt;/th&gt;
      &lt;th&gt;G&lt;/th&gt;&lt;th&gt;O&lt;/th&gt;&quot;;
$bingocard .= &quot;&lt;/tr&gt;&lt;/thead&gt;&quot;;
$bingocard .= &quot;&lt;tbody&gt;&quot;;
$bingocard .= &quot;&lt;tr&gt;&quot;;

// here's the gap 

$bingocard .= &quot;&lt;/tr&gt;&quot;;
$bingocard .= &quot;&lt;/tbody&gt;&quot;;
$bingocard .= &quot;&lt;/table&gt;&quot;;</code></pre>
<h2>
  Step 5: Create Cells and Rows<br />
</h2>
<p>
  We now need to create 25 cells from the items in our buzzwords array. We&#8217;ll use a <code>for</code> loop to iterate through the items in our shuffled array 25 times, and create a table cell for each. That <code>for</code> loop goes in the gap we left in the previous step.
</p>
<div id="adz" class="vertical"></div><p>
  Our table will be a 5&#215;5 grid, so we&#8217;ll also need to create five rows, each with five cells. We already prepared the start of our first row and the end of our last row, so we&#8217;ll also need to double-check to make sure we don&#8217;t do this on the last cell.
</p>
<p>
  To work that out, I&#8217;ve used a variable <code>$rowend</code>, which is the remainder of <code>$cell</code> + 1, divided by five. After we create each cell, there&#8217;s a small <code>if</code> statement to check whether a <code>$rowend</code> is zero, and that it isn&#8217;t the 25th cell. If that&#8217;s the case, we&#8217;ll close and open a table row element.
</p>
<p>
  Here&#8217;s the <code>for</code> loop:
</p>
<pre><code>for($cell=0; $cell&lt;25; $cell++)
  {
    $rowend = ($cell + 1) % 5;
    $bingocard .= &quot;&lt;td&gt;&quot; 
     . $buzzwords[$cell] . &quot;&lt;/td&gt;&quot;;
    if($rowend == 0 &amp;&amp; $cell &lt; 24) {
      $bingocard .= &quot;&lt;/tr&gt;\n&lt;tr&gt;&quot;;
    }
  }</code></pre>
<h2>
  Step 6: Echo the Table<br />
</h2>
<p>
  We&#8217;ve built an array, shuffled it, and made it into a table. All that&#8217;s left to do now is print it:
</p>
<pre><code>echo $bingocard;</code></pre>
<p>
  &#8230; and we&#8217;re nearly done! You should now have a PHP file that looks similar to <a href="http://www.sitepoint.com/examples/buzzwordbingo/bingo.phps">Example 1</a>.
</p>
<h2>
  Step 7: Drop It in A Document<br />
</h2>
<p>
  Let&#8217;s now use this function in a web page. Include the <code>bingo.php</code> file at the start of the document:
</p>
<pre><code>&lt;?php include ('/path/to/bingo.php'); ?&gt;</code></pre>
<p>
  Now call on the <code>Bingo</code> function wherever you need to put your card:
</p>
<pre><code>&lt;?php Bingo(); ?&gt;</code></pre>
<p>
  Use some CSS to style the buzzword bingo table how you&#8217;d like. You can see a very plain example of a bingo card in <a href="http://www.sitepoint.com/examples/buzzwordbingo/playbingo.phps">Example 2</a>, and the results in <a href="http://www.sitepoint.com/examples/buzzwordbingo/playbingo.php">Example 3</a>. You might even like to layer on some JavaScript to let players check off each cell by clicking on it, or cause an amusing effect when the player achieves bingo.
</p>
<h2>
  Step 8: Play!<br />
</h2>
<p>
  When you&#8217;re happy with how your card looks, it&#8217;s time to pass on the URL of the bingo card to your co-workers. Next time there&#8217;s a meeting, print a copy for every player, and see who can call bingo first!</p>
<script src="http://ads.aws.sitepoint.com/adjs.php?region=136&amp;did=adz&amp;adtype=vertical" type="text/javascript"></script>]]></content:encoded>
			<wfw:commentRss>http://www.sitepoint.com/blogs/2009/03/03/build-a-buzzword-bingo-card-in-php/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.911 seconds -->
<!-- Cached page served by WP-Cache -->
