<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="Newsletter Manager" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
>

<channel>
	<title>The PHPit Digest</title>
	<link>http://digest.phpit.net</link>
	<description>Weekly PHP news, articles, tips and tricks!</description>
	<copyright>Copyright 2004-2005</copyright>

	<pubDate>Tue, 29 Aug 2006 02:00:00 GMT</pubDate>

	<item>
		<title>PHPit Digest #23 - Taking Zend Certification, MVC system, count vs sizeof...</title>
		<link>http://digest.phpit.net/archives/23/html/</link>
		<pubDate>Tue, 29 Aug 2006 02:00:00 GMT</pubDate>
		<guid>issue23</guid>
		<description>The PHPit Digest
Weekly PHP news, articles, tips and tricks!

Newsletter Archives - http://digest.phpit.net/
Advertising - http://www.phpit.net/advertising/
Contact - http://www.phpit.net/contact/

----------------------------------------------------

In This Issue...

* Introduction: Zend Certification
* The Latest PHP Articles From Around The &#039;Net
* Excerpt: Building a simple MVC system with PHP5
* The Latest PHP Blog Posts From Around The &#039;Net
* Quick Tip: use sizeof() instead of count()
* The Latest PHP Discussions From Around The &#039;Net
* Closing Words

----------------------------------------------------

Introduction: Zend Certification

Welcome to this new issue of the PHPit Digest, once again filled with the latest PHP articles, information, and more.

I&#039;m very happy to announce that I&#039;m taking the Zend Certification in a month or two. I&#039;ve just ordered a voucher, and two study guides, which hopefully means I will be able to take the exam very soon. And I&#039;m taking the new PHP5 certification exam (http://www.zend.com/education/zend_php_certification/php_5_certification/), which has just been released, and covers some really interesting topics. I can&#039;t wait to get started, and I&#039;ll be sure to keep you all updated on my progress.

This issue of the Digest contains the usual sections, and there are plenty of great links to be found, including several articles on Design Patterns, two forum threads on database abstraction libraries, and more.

 Happy Reading!

Dennis Pallett
dennis@phpit.net 

----------------------------------------------------

The Latest PHP Articles From Around The &#039;Net

There have been quite a lot of new PHP articles in the past two weeks, and some of them are really interesting. Let&#039;s take a look at the best ones.

First up is IBM&#039;s developerWorks with &quot;Understanding the Zend Framework, Part 5: Creating PDF files&quot; (http://www-128.ibm.com/developerworks/edu/os-dw-os-php-zend5.html), in which you will learn how to create a PDF document with the Zend Framework. Part six, &quot;Understanding the Zend Framework, Part 6: Sending e-mail&quot; (http://www-128.ibm.com/developerworks/library/os-php-zend6/index.html), has also been posted already, and shows you how to use the Zend_Mail component to send text and HTML e-mail alerts to users when new content has been added to subscribed feeds.

If you want to learn more about design patterns you&#039;re in luck, because a whole slew of design pattern and OOP related articles have been published by several different websites.  DevShed has posted the final part in their &quot;Introducing Visitor Objects in  PHP5&quot; series, and in this part (http://www.devshed.com/c/a/PHP/Using-Visitor-Objects-with-MySQL-Data-Sets-in-PHP-5/) you are shown how to use the Visitor Object pattern together with MySQL data sets.

If you simple want a good introduction to OOP, NefariusDesigns has posted a three-part article series on various OOP concepts. In the first part, &quot;Object-Oriented PHP Part 1: Definition&quot; (http://nefariousdesigns.co.uk/archive/2006/08/object-oriented-php-part-1-definition/) you are introduced to some basic class and OOP concepts, such as class, $this, objects, constructor, destructor and more. Then in the second part, &quot;Object-Oriented PHP Part 2: Relationships&quot; (http://nefariousdesigns.co.uk/archive/2006/08/object-oriented-php-part-2-relationships/), the author talks about relationships between classes, and explains inheritance, composition, aggregation, references and more. Finally, in the third part, &quot;Object-Oriented PHP Part 3: Taking Relationships Further&quot; (http://nefariousdesigns.co.uk/archive/2006/08/object-oriented-php-part-3-taking-relationships-further/), you learn about visibility modifiers, polymorphism and the scope resolution operator.

If you still can&#039;t get enough of Design Patterns, have a look at &quot;Observers and Dispatchers&quot; (http://www.flyingwithfire.com/2006/08/24/observers-and-dispatchers/) which explains the Observer and Dispatcher design patterns.

Moving away from design patterns, in &quot;Reading, Writing and Creating Files in PHP&quot; (http://www.devshed.com/c/a/PHP/Reading-Writing-and-Creating-Files-in-PHP/) you get introduced to PHP&#039;s file functions. This is mainly a tutorial for beginners, as most of the things explained in this tutorial are quite obvious to an experienced PHP developer.

And last, but certainly not least, PHPit has a new article called &quot;Building a simple MVC system with PHP5&quot; (http://www.phpit.net/article/simple-mvc-php5/), in which you are shown how to completely build an MVC script from scratch, and you will learn how to create a Registry class, use the __autoload() functionality of PHP5, setup a Router() class and more.

 To view a complete list of all the latest PHP articles, have a look at Webdev-Articles (http://www.webdev-articles.com/category/php) 


----------------------------------------------------

Excerpt: Building a simple MVC system with PHP5

Welcome to the first full-blown PHP5 tutorial on PHPit, and you&#039;ll need to have PHP5.1 and SPL installed for this tutorial, because we&#039;ll be using some of PHP5&#039;s latest features.

In this tutorial I&#039;m going to show you how to build a simple Model-View-Controller system, which is the most common design pattern for big web applications. I&#039;ll take you through all the steps necessary to start from scratch to a full-blown MVC system.

 Click here to read the rest of this article &amp;raquo; (http://www.phpit.net/article/simple-mvc-php5/) 

----------------------------------------------------

The Latest PHP Blog Posts From Around The &#039;Net

Let&#039;s take a look at the best blog posts on Planet PHP (http://www.planet-php.net/) from the past two weeks.

In &quot;PDO Turbo Button&quot; (http://doughboy.wordpress.com/2006/08/25/pdo-turbo-button/) Brian Moon does some benchmarking tests between PDO, the mysql extension, and the mysqli extension. His blog entry includes a way of speeding up PDO SELECT queries using a simple trick.

Adam Trachterberg posts about a nice little one-liner (http://www.trachtenberg.com/blog/2006/08/24/stupid-php-one-liners-google-calc/) that uses the Google Calculator functionality to create a simple command line calculator which supports almost any calculation (since it uses the Google Calculator).

Ivo Jansch talks about something called &quot;Mixins in PHP&quot; (http://www.achievo.org/blog/archives/46-Mixins-in-PHP.html), which comes from Ruby, and can be used to mix two classes together to form a single class. He uses PHP5&#039;s overloading functionality (__call) to dynamically mix two classes together in one class, which is pretty neat, although I doubt it has any real practical use.

The ThinkPHP blog has a little tip for those who are using the lighthttpd webserver and need to stream large files with PHP. Apparently, lighthttpd has a feature called X-Sendfile, which is used to stream files very efficiently. Check the blog post (http://blog.thinkphp.de/archives/136-Make-the-download-of-large-files-with-PHP-and-lighty-very-easy.html) for more information and a demonstration.

In &quot;Advanced Caching Technique - Block Randomization&quot; (http://syntux.net/blog/2006/08/21/advanced-caching-technique-block-randomization/) Jad Madi blogs about a caching technique called &quot;block randomization&quot; and demonstrates the concept with some sample code. Pretty interesting entry, and the concept seems quite useful, although very simple.

In &quot;Creating PEAR-installable nightly builds&quot; (http://blog.php-tools.net/archives/147-Creating-PEAR-installable-nightly-builds.html) on the PHP-Tools blog you will learn how to create nightly builds that include a PEAR installable package. Usually nightly builds come as a ZIP and TAR.GZ file, but this blog entry also shows you how to create a PEAR package on-the-fly.

Let&#039;s finish with Evert Pot&#039;s &quot;Creating a Gopher server with PHP and InetD&quot; (http://www.rooftopsolutions.nl/article/100) entry, where he shows you how to create an old-school gopher server with PHP and something called &quot;inetD&quot;. It seems that inetD is something for Linux only, so it won&#039;t work on Windows, but it&#039;s still an interesting entry nonetheless.

----------------------------------------------------

Quick Tip: use sizeof() instead of count()

If you&#039;re writing a PHP5 script, use the sizeof() function instead of count(). Although the manual says that sizeof() is a simple alias for count(), sizeof() is actually twice as fast, and can give a slight increase in performance, especially when used a lot.

In one of my scripts I saw performance increase by a whole second by using sizeof() instead of count(). I&#039;m not sure why this is, especially since it&#039;s officially an alias, but that&#039;s just the way it is. Use it to your advantage!


----------------------------------------------------

The Latest PHP Discussions From Around The &#039;Net

As usual there have been plenty of great PHP discussions on the various PHP forums, so let&#039;s go through the best ones.

In &quot;Best way to database independant applications?&quot; (http://www.sitepoint.com/forums/showthread.php?t=415930) the thread starter wants to know how to create portable scripts that can run on any type of database (i.e. MySQL, PostgreSQL, MSSQL, etc). This is a topic that comes up a lot, and the usual answer is to use an abstraction library, such as PDO or AdoDB, but in reality it&#039;s not as easy as that. Read the thread for more information and some suggestions on the right library to use.

Related to this thread is &quot;Database abstraction layers (creole, adodb) - opinions and comparison&quot; (http://www.sitepoint.com/forums/showthread.php?t=407306) in which the forum members take a look at various DB libraries and give their personal opinion on PDO, Creole, AdoDb and a few others.

In &quot;code separation / mvc / need real-life advice&quot; (http://www.sitepoint.com/forums/showthread.php?t=415117) the thread starters needs some advice on creating a MVC system, and how to handle all the different needs of his script. Many of SitePoint&#039;s veteran PHP developers jump in, and give suggestions, so this thread is highly worth reading if you need some real-life advice as well.

Whilst we&#039;re on the topic of an MVC system, in &quot;Difference between front and application controllers?&quot; (http://www.sitepoint.com/forums/showthread.php?t=416388) the thread starter wants to know what the difference is between a front and application controller. Several members try to explain the difference, although each explanation is slightly different, which makes a bit confusing, but this thread is still a good resource if you&#039;re not exactly sure about the difference either.

If you&#039;ve got difficulty with designing your PHP application or its classes, have a look at &quot;How to plan your classes&quot; (http://www.sitepoint.com/forums/showthread.php?t=415801), in which the thread starter wants to know what the best way is to plan your classes. Some great advice is given when it comes to planning classes, and various topics such as UML and Test-Driven Development are discussed by the SitePoint members.

Related to the Editor&#039;s Perspective of the previous Digest on character encodings is &quot;Another thread on UTF-8 and other encodings...&quot; (http://forums.devnetwork.net/viewtopic.php?t=54462), which is all about UTF-8 and other character encodings, and how to handle it in PHP. Almost everything on character encodings is discussed, and this thread is a great resource if you&#039;re still somewhat unsure about character encodings.

In &quot;Parameter Object vs. Parameter Array vs. Parameter Functions&quot; (http://forums.devnetwork.net/viewtopic.php?t=54478) the thread starter is looking for an elegant solution when a function gets too many arguments. Common solutions include passing the arguments as an array or an object, and that&#039;s exactly what the thread starter does. A good solution would be named arguments, but unfortunately PHP doesn&#039;t support this.

Lastly, in &quot;understanding php permissions (and servers/OS&#039;s)&quot; (http://forums.devnetwork.net/viewtopic.php?t=54457) the forum members talk about file permissions and how it relates to PHP&#039;s ability to read/write files. No PHP code in this thread, but a lot of information on how file permissions work and how to lock down your files as secure as possible.

----------------------------------------------------

Closing Words

That&#039;s it again for this issue, and I hope you enjoyed it. As always, if you have any suggestions or comments, please e-mail me at dennis@phpit.net.

The next issue of the Digest will arrive in your inbox on or around September 12th.

Until then, enjoy more PHP articles on PHPit (http://www.phpit.net) and join us at PHPit Forums (http://www.phpit.net/forums/).

----------------------------------------------------

If you no longer wish to receive the PHPit Digest you can unsubscribe by going to the following URL:
http://www.aspit.net/dada/mail.cgi?f=u&amp;l=phpit&amp;e=[subscriber_email]&amp;p=[pin]</description>
		<content:encoded><![CDATA[<b>The PHPit Digest</b><br />
<i>Weekly PHP news, articles, tips and tricks!</i><br /><br />

Newsletter Archives - <a href="http://digest.phpit.net/">http://digest.phpit.net/</a><br />
Advertising - <a href="http://www.phpit.net/advertising/">http://www.phpit.net/advertising/</a><br />
Contact - <a href="http://www.phpit.net/contact/">http://www.phpit.net/contact/</a><br /><br />

----------------------------------------------------<br /><br />

<b>In This Issue...</b><br /><br />

* Introduction: Zend Certification<br />
* The Latest PHP Articles From Around The 'Net<br />
* Excerpt: Building a simple MVC system with PHP5<br />
* The Latest PHP Blog Posts From Around The 'Net<br />
* Quick Tip: use sizeof() instead of count()<br />
* The Latest PHP Discussions From Around The 'Net<br />
* Closing Words<br />

<br />----------------------------------------------------<br /><br />

<b>Introduction: Zend Certification</b><br /><br />

Welcome to this new issue of the PHPit Digest, once again filled with the latest PHP articles, information, and more.<br />
<br />
I'm very happy to announce that I'm taking the Zend Certification in a month or two. I've just ordered a voucher, and two study guides, which hopefully means I will be able to take the exam very soon. And I'm taking the new <a href="http://www.zend.com/education/zend_php_certification/php_5_certification/">PHP5 certification exam</a>, which has just been released, and covers some really interesting topics. I can't wait to get started, and I'll be sure to keep you all updated on my progress.<br />
<br />
This issue of the Digest contains the usual sections, and there are plenty of great links to be found, including several articles on Design Patterns, two forum threads on database abstraction libraries, and more.<br />
<br />
<b>Happy Reading!<br />
<br />
Dennis Pallett<br />
dennis@phpit.net</b>

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Articles From Around The 'Net</b><br /><br />

There have been quite a lot of new PHP articles in the past two weeks, and some of them are really interesting. Let's take a look at the best ones.<br />
<br />
First up is IBM's developerWorks with <a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-zend5.html">"Understanding the Zend Framework, Part 5: Creating PDF files"</a>, in which you will learn how to create a PDF document with the Zend Framework. Part six, <a href="http://www-128.ibm.com/developerworks/library/os-php-zend6/index.html">"Understanding the Zend Framework, Part 6: Sending e-mail"</a>, has also been posted already, and shows you how to use the Zend_Mail component to send text and HTML e-mail alerts to users when new content has been added to subscribed feeds.<br />
<br />
If you want to learn more about design patterns you're in luck, because a whole slew of design pattern and OOP related articles have been published by several different websites.  DevShed has posted the final part in their "Introducing Visitor Objects in  PHP5" series, and in <a href="http://www.devshed.com/c/a/PHP/Using-Visitor-Objects-with-MySQL-Data-Sets-in-PHP-5/">this part</a> you are shown how to use the Visitor Object pattern together with MySQL data sets.<br />
<br />
If you simple want a good introduction to OOP, NefariusDesigns has posted a three-part article series on various OOP concepts. In the first part, <a href="http://nefariousdesigns.co.uk/archive/2006/08/object-oriented-php-part-1-definition/">"Object-Oriented PHP Part 1: Definition"</a> you are introduced to some basic class and OOP concepts, such as class, $this, objects, constructor, destructor and more. Then in the second part, <a href="http://nefariousdesigns.co.uk/archive/2006/08/object-oriented-php-part-2-relationships/">"Object-Oriented PHP Part 2: Relationships"</a>, the author talks about relationships between classes, and explains inheritance, composition, aggregation, references and more. Finally, in the third part, <a href="http://nefariousdesigns.co.uk/archive/2006/08/object-oriented-php-part-3-taking-relationships-further/">"Object-Oriented PHP Part 3: Taking Relationships Further"</a>, you learn about visibility modifiers, polymorphism and the scope resolution operator.<br />
<br />
If you still can't get enough of Design Patterns, have a look at <a href="http://www.flyingwithfire.com/2006/08/24/observers-and-dispatchers/">"Observers and Dispatchers"</a> which explains the Observer and Dispatcher design patterns.<br />
<br />
Moving away from design patterns, in <a href="http://www.devshed.com/c/a/PHP/Reading-Writing-and-Creating-Files-in-PHP/">"Reading, Writing and Creating Files in PHP"</a> you get introduced to PHP's file functions. This is mainly a tutorial for beginners, as most of the things explained in this tutorial are quite obvious to an experienced PHP developer.<br />
<br />
And last, but certainly not least, PHPit has a new article called <a href="http://www.phpit.net/article/simple-mvc-php5/">"Building a simple MVC system with PHP5"</a>, in which you are shown how to completely build an MVC script from scratch, and you will learn how to create a Registry class, use the __autoload() functionality of PHP5, setup a Router() class and more.<br />
<br />
<em>To view a complete list of all the latest PHP articles, have a look at <a href="http://www.webdev-articles.com/category/php">Webdev-Articles</a></em><br />


<br /><br />----------------------------------------------------<br /><br />

<b>Excerpt: Building a simple MVC system with PHP5</b><br /><br />

Welcome to the first full-blown PHP5 tutorial on PHPit, and you'll need to have PHP5.1 and SPL installed for this tutorial, because we'll be using some of PHP5's latest features.<br />
<br />
In this tutorial I'm going to show you how to build a simple Model-View-Controller system, which is the most common design pattern for big web applications. I'll take you through all the steps necessary to start from scratch to a full-blown MVC system.<br />
<br />
<em><a href="http://www.phpit.net/article/simple-mvc-php5/">Click here to read the rest of this article &raquo;</a></em>

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Blog Posts From Around The 'Net</b><br /><br />

Let's take a look at the best blog posts on <a href="http://www.planet-php.net/">Planet PHP</a> from the past two weeks.<br />
<br />
In <a href="http://doughboy.wordpress.com/2006/08/25/pdo-turbo-button/">"PDO Turbo Button"</a> Brian Moon does some benchmarking tests between PDO, the mysql extension, and the mysqli extension. His blog entry includes a way of speeding up PDO SELECT queries using a simple trick.<br />
<br />
Adam Trachterberg <a href="http://www.trachtenberg.com/blog/2006/08/24/stupid-php-one-liners-google-calc/">posts about a nice little one-liner</a> that uses the Google Calculator functionality to create a simple command line calculator which supports almost any calculation (since it uses the Google Calculator).<br />
<br />
Ivo Jansch talks about something called <a href="http://www.achievo.org/blog/archives/46-Mixins-in-PHP.html">"Mixins in PHP"</a>, which comes from Ruby, and can be used to mix two classes together to form a single class. He uses PHP5's overloading functionality (__call) to dynamically mix two classes together in one class, which is pretty neat, although I doubt it has any real practical use.<br />
<br />
The ThinkPHP blog has a little tip for those who are using the lighthttpd webserver and need to stream large files with PHP. Apparently, lighthttpd has a feature called X-Sendfile, which is used to stream files very efficiently. Check the <a href="http://blog.thinkphp.de/archives/136-Make-the-download-of-large-files-with-PHP-and-lighty-very-easy.html">blog post</a> for more information and a demonstration.<br />
<br />
In <a href="http://syntux.net/blog/2006/08/21/advanced-caching-technique-block-randomization/">"Advanced Caching Technique - Block Randomization"</a> Jad Madi blogs about a caching technique called "block randomization" and demonstrates the concept with some sample code. Pretty interesting entry, and the concept seems quite useful, although very simple.<br />
<br />
In <a href="http://blog.php-tools.net/archives/147-Creating-PEAR-installable-nightly-builds.html">"Creating PEAR-installable nightly builds"</a> on the PHP-Tools blog you will learn how to create nightly builds that include a PEAR installable package. Usually nightly builds come as a ZIP and TAR.GZ file, but this blog entry also shows you how to create a PEAR package on-the-fly.<br />
<br />
Let's finish with Evert Pot's <a href="http://www.rooftopsolutions.nl/article/100">"Creating a Gopher server with PHP and InetD"</a> entry, where he shows you how to create an old-school gopher server with PHP and something called "inetD". It seems that inetD is something for Linux only, so it won't work on Windows, but it's still an interesting entry nonetheless.

<br /><br />----------------------------------------------------<br /><br />

<b>Quick Tip: use sizeof() instead of count()</b><br /><br />

If you're writing a PHP5 script, use the sizeof() function instead of count(). Although the manual says that sizeof() is a simple alias for count(), sizeof() is actually twice as fast, and can give a slight increase in performance, especially when used a lot.<br />
<br />
In one of my scripts I saw performance increase by a whole second by using sizeof() instead of count(). I'm not sure why this is, especially since it's officially an alias, but that's just the way it is. Use it to your advantage!<br />


<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Discussions From Around The 'Net</b><br /><br />

As usual there have been plenty of great PHP discussions on the various PHP forums, so let's go through the best ones.<br />
<br />
In <a href="http://www.sitepoint.com/forums/showthread.php?t=415930">"Best way to database independant applications?"</a> the thread starter wants to know how to create portable scripts that can run on any type of database (i.e. MySQL, PostgreSQL, MSSQL, etc). This is a topic that comes up a lot, and the usual answer is to use an abstraction library, such as PDO or AdoDB, but in reality it's not as easy as that. Read the thread for more information and some suggestions on the right library to use.<br />
<br />
Related to this thread is <a href="http://www.sitepoint.com/forums/showthread.php?t=407306">"Database abstraction layers (creole, adodb) - opinions and comparison"</a> in which the forum members take a look at various DB libraries and give their personal opinion on PDO, Creole, AdoDb and a few others.<br />
<br />
In <a href="http://www.sitepoint.com/forums/showthread.php?t=415117">"code separation / mvc / need real-life advice"</a> the thread starters needs some advice on creating a MVC system, and how to handle all the different needs of his script. Many of SitePoint's veteran PHP developers jump in, and give suggestions, so this thread is highly worth reading if you need some real-life advice as well.<br />
<br />
Whilst we're on the topic of an MVC system, in <a href="http://www.sitepoint.com/forums/showthread.php?t=416388">"Difference between front and application controllers?"</a> the thread starter wants to know what the difference is between a front and application controller. Several members try to explain the difference, although each explanation is slightly different, which makes a bit confusing, but this thread is still a good resource if you're not exactly sure about the difference either.<br />
<br />
If you've got difficulty with designing your PHP application or its classes, have a look at <a href="http://www.sitepoint.com/forums/showthread.php?t=415801">"How to plan your classes"</a>, in which the thread starter wants to know what the best way is to plan your classes. Some great advice is given when it comes to planning classes, and various topics such as UML and Test-Driven Development are discussed by the SitePoint members.<br />
<br />
Related to the Editor's Perspective of the previous Digest on character encodings is <a href="http://forums.devnetwork.net/viewtopic.php?t=54462">"Another thread on UTF-8 and other encodings..."</a>, which is all about UTF-8 and other character encodings, and how to handle it in PHP. Almost everything on character encodings is discussed, and this thread is a great resource if you're still somewhat unsure about character encodings.<br />
<br />
In <a href="http://forums.devnetwork.net/viewtopic.php?t=54478">"Parameter Object vs. Parameter Array vs. Parameter Functions"</a> the thread starter is looking for an elegant solution when a function gets too many arguments. Common solutions include passing the arguments as an array or an object, and that's exactly what the thread starter does. A good solution would be named arguments, but unfortunately PHP doesn't support this.<br />
<br />
Lastly, in <a href="http://forums.devnetwork.net/viewtopic.php?t=54457">"understanding php permissions (and servers/OS's)"</a> the forum members talk about file permissions and how it relates to PHP's ability to read/write files. No PHP code in this thread, but a lot of information on how file permissions work and how to lock down your files as secure as possible.

<br /><br />----------------------------------------------------<br /><br />

<b>Closing Words</b><br /><br />

That's it again for this issue, and I hope you enjoyed it. As always, if you have any suggestions or comments, please e-mail me at dennis@phpit.net.<br />
<br />
The next issue of the Digest will arrive in your inbox on or around September 12th.<br />
<br />
Until then, enjoy more PHP articles on <a href="http://www.phpit.net">PHPit</a> and join us at <a href="http://www.phpit.net/forums/">PHPit Forums</a>.

<br /><br />----------------------------------------------------<br /><br />


If you want to receive the PHPit Digest through e-mail (either in HTML or Plain Text format), you can do so, by subscribing <a href="http://www.aspit.net/dada/mail.cgi?f=list&l=phpit">here</a>.]]></content:encoded>	
	</item>
	<item>
		<title>PHPit Digest #22 - Character encoding difficult?, creating images with GD...</title>
		<link>http://digest.phpit.net/archives/22/html/</link>
		<pubDate>Tue, 15 Aug 2006 02:00:00 GMT</pubDate>
		<guid>issue22</guid>
		<description>The PHPit Digest
Weekly PHP news, articles, tips and tricks!

Newsletter Archives - http://digest.phpit.net/
Advertising - http://www.phpit.net/advertising/
Contact - http://www.phpit.net/contact/

----------------------------------------------------

In This Issue...

* Introduction: Editor&#039;s Perspective
* Editor&#039;s Perspective: character sets, encoding and more
* The Latest PHP Articles From Around The &#039;Net
* Excerpt: Image manipulation with PHP &amp; the GD library, Part 2
* The Latest PHP Blog Posts From Around The &#039;Net
* The Latest PHP Discussions From Around The &#039;Net
* Closing Words

----------------------------------------------------

Introduction: Editor&#039;s Perspective

Welcome to this new issue of the PHPit Digest, once again filled with the latest news and information on PHP and MySQL.

This issue comes with an Editor&#039;s Perspective again, and this time I talk a bit about character encoding and UTF-8. Even though UTF-8 has existed for many years now, PHP still doesn&#039;t support it, and won&#039;t support it until PHP6. Read more about this &quot;problem&quot; in the Editor&#039;s Perspective.

The rest of the Digest comes with the usual sections covering the latest PHP articles, blog entries, forum threads and the newest PHPit article.

 Happy Reading!

Dennis Pallett
dennis@phpit.net  

----------------------------------------------------

Editor&#039;s Perspective: character sets, encoding and more

Character encoding is still a big problem in PHP, mainly because PHP doesn&#039;t support any character encoding whatsoever. Can your scripts handle UTF-8 text? Probably not.

The biggest problem is that PHP simply thinks that 1 byte = 1 character. Therefore, if you have some text that contains multibyte characters, PHP will report the incorrect length. The following example demonstrates this:

[php]
 
[/php]

If we count it by hand, we can see that it&#039;s 20 characters. But PHP will report 27 characters, because there are several multibyte characters. That&#039;s just one of the problems with PHP&#039;s lack of UTF-8 support. Another problem is that you can&#039;t use the strtolower or strtoupper functions either, because PHP only support the basic characters, and will ignore (or even mangle) all the other characters.

This means that you can&#039;t actually use PHP&#039;s string functions, unless you are absolutely certain that there will be no multibyte characters, but these days you can&#039;t really be sure of that, because the internet is global and accessed by everyone all over the world.

Thankfully, Harry Fuecks has posted tons of tips on handling UTF-8 in PHP. In his blog entry (http://www.sitepoint.com/blogs/2006/08/10/hot-php-utf-8-tips/) () he gives several tips and tricks when dealing with UTF-8, and he has even created the PHP UTF-8 (http://sourceforge.net/projects/phputf8) () project, which can be used to handle UTF-8 without having to use the mbstring() library.

PHPWact has also got an extremely useful page (http://www.phpwact.org/php/i18n/charsets) () available where the problem is very clearly explained, and every solution is discussed. This page is a must-read if you&#039;re still not sure what the problem is.

PHP&#039;s next major version, PHP6, will be able any character encoding, including UTF-8, but PHP6 is still far away, and it&#039;s important that your PHP scripts support Unicode today, especially as the internet becomes more international every day.

(If you&#039;re looking for a history lesson on character sets and encoding, have a look at Joel Spolsky&#039;s &quot;The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets&quot; (http://www.joelonsoftware.com/articles/Unicode.html) article).

----------------------------------------------------

The Latest PHP Articles From Around The &#039;Net

Let&#039;s take a look at the best PHP articles from the past two weeks.

First up is DevShed&#039;s &quot;Introducing Visitor Objects in PHP 5&quot; (http://www.devshed.com/c/a/PHP/Introducing-Visitor-Objects-in-PHP-5/), in which you are introduced to the Visitor design pattern in PHP5. You will learn what Visitor objects are, and see such an object in action. In the second part, &quot;Expanding the Application Range of Visitor Objects in PHP 5&quot; (http://www.devshed.com/c/a/PHP/Expanding-the-Application-Range-of-Visitor-Objects-in-PHP-5/), the author shows you more examples of the usage of Visitor Objects in practical examples.

In &quot;Creating images using GD&quot; (http://www.phphacks.com/content/view/21/33/) you learn how to create images and thumbnails with PHP and the GD library. The author shows you how to enable the GD library and how to generate thumbnails from existing images.

And if you want to know more about PHP&#039;s image functions and the GD library, have a look at &quot;Image manipulation with PHP, Part 2&quot; (http://www.phpit.net/article/image-manipulation-php-gd-part2/), in which you will learn how to resize images, and watermark them. You will also see how to build a simple online image resizing tool.

DevShed has also started a new series on implementing the MVC design in PHP. In the first part, &quot;An Introduction to Simulating the Model-View-Controller Schema in PHP&quot; (http://www.devshed.com/c/a/PHP/An-Introduction-to-Simulating-the-Model-View-Controller-Schema-in-PHP/), you are introduced to the MVC schema, and shown how to construct a basic PHP controller. In the second part, &quot;Building a Web Page Controller for Simulating the Model-View-Controller Schema in PHP&quot; (http://www.devshed.com/c/a/PHP/Building-a-Web-Page-Controller-for-Simulating-the-Model-View-Controller-Schema-in-PHP/), you will see how to create a web page controller class and a style sheet generator class.

If you&#039;re still somewhat of a beginner, and want to learn more about PHP&#039;s class and object support have a look at &quot;Classes as PHP Functions&quot; (http://www.devshed.com/c/a/PHP/Classes-as-PHP-Functions/) or &quot;Getting your head around PHP objects&quot; (http://www.tectonic.co.za/view.php?id=1094). In both articles you are introduced to the use of objects, methods, and properties.

And finally, in &quot;How to create Microsoft Office documents on the fly using PHP&quot; (http://web.informbank.com/articles/technology/php-office-documents.htm) you are shown how to create MS Office (Word, Powerpoint, Excel, etc) documents dynamically using PHP.

 To view a complete list of all the latest PHP articles, have a look at Webdev-Articles (http://www.webdev-articles.com/category/php) 

----------------------------------------------------

Excerpt: Image manipulation with PHP &amp; the GD library, Part 2

Welcome to the second part of the &quot;Image manipulation with PHP &amp; the GD library&quot; article series, and in this part we&#039;ll take a look at how to resize images, create thumbnails, watermark images and more using PHP&#039;s image functions.

If you haven&#039;t read the first part, I recommend you do so before reading this part, because I will talk about several things we&#039;ve done in the previous part.

Let&#039;s get started with resizing images and creating thumbnails.

 Click here to read the rest of this article &amp;raquo; (http://www.phpit.net/article/image-manipulation-php-gd-part2/) 

----------------------------------------------------

The Latest PHP Blog Posts From Around The &#039;Net

Let&#039;s take a look at the most interesting blog posts covering PHP and MySQL from the past two weeks.

Ligaya Turmelle points (http://www.khankennels.com/blog/index.php/archives/2006/08/13/good-article-on-database-abstraction/) to an article on the different types of database abstraction (http://www.xaprb.com/blog/2006/08/13/four-types-of-database-abstraction-layers/). In this article the author discusses the different types, and discuses the cons and pros of each type.

In &quot;SQL_CALC_FOUND_ROWS and Faster Count(*) Alternatives&quot; (http://fuzzyblog.com/archives/2006/08/12/sql_calc_found_rows-and-faster-count-alternatives/) Scott Johnson talks about a little MySQL trick that can be used to speed up pagination of results. Usually when doing pagination you first issue a SELECT COUNT(*) query to get the number of results, and then select the actual results you want. In this blog entry Scott gives you another way, that&#039;s also faster.

In the previous issue of the Digest, I pointed to an article by IBM&#039;s developerWorks called &quot;Five common PHP database problems&quot; (http://www-128.ibm.com/developerworks/opensource/library/os-php-dbmistake/?ca=dgr-lnxw97Avoid5PHPerrors). Brian Moon has posted an entry (http://doughboy.wordpress.com/2006/08/11/mysqlphp-problems/) to this article, and posted some of his thoughts on the things mentioned in the article, and his entry is definitely worth reading to learn more about the database problems.

Ilia Alshanetsky posts (http://ilia.ws/index.php?url=archives/121-httpOnly-cookie-flag-support-in-PHP-5.2.html) about one of PHP 5.2&#039;s new features: HttpOnly cookies. HttpOnly cookies are used to prevent JavaScript from reading cookies set in PHP. At the moment this can only be down with the Header() function, and not with the setcookie() function, but in PHP5.2 this will be possible with the setcookie() function.

As I mentioned in the Editor&#039;s Perspective, Harry Fuecks has posted two blog entries on handling UTF-8 in PHP. In his first entry, &quot;Scripters UTF-8 Survival Guide (slides)&quot; (http://www.sitepoint.com/blogs/2006/08/09/scripters-utf-8-survival-guide-slides/), he provides a pointer to the slides of a recent presentation on this topic. And in the second entry, &quot;Hot PHP UTF-8 tips&quot; (http://www.sitepoint.com/blogs/2006/08/10/hot-php-utf-8-tips/), he provides a whole list of tips and tricks on handling UTF-8 in PHP.

If you want to help out the PHP project, have a look at &quot;25 Ways to help out PHP&quot; (http://www.khankennels.com/blog/index.php/archives/2006/08/10/25-ways-to-help-out-php/) which lists 25 different ways of helping the PHP project, ranging from simple bug reports to advocating PHP to actually patching the PHP core.

And finally, Jad Madi writes (http://syntux.net/blog/2006/08/08/php5-certification-exam/) about his experience taking the new PHP5 Certification Exam, which will be available very soon to everyone. Not a lot of information in his entry, but it still provides some insight into the new exam.

----------------------------------------------------

The Latest PHP Discussions From Around The &#039;Net

There have been plenty of great PHP discussions in the past two weeks, so let&#039;s take a look and check out the best ones.

In &quot;APIs&quot; (http://www.sitepoint.com/forums/showthread.php?t=412061) the thread starter wants to know when to re-invent the wheel and create his own libraries and when to use another library / API. As always, opinions differ and many replies are given, but the general reply seems to be that you just have to find a middle ground that you&#039;re comfortable with.

Next, in &quot;Frameworks that are actually used?&quot; (http://www.sitepoint.com/forums/showthread.php?t=408530) Dan Grossman is looking for suggestions for PHP frameworks that are actually used in real live web applications. Although many PHP frameworks have plenty of examples and such, they still lack any real world usage, and that&#039;s an important thing. If you&#039;re looking for the same thing, have a look at this thread to see which framework Dan eventually chose.

In &quot;Best Practice - mysql database query&quot; (http://www.sitepoint.com/forums/showthread.php?t=407037) some basics of querying the database is discussed, and the fastest way to do this. Not a lot of PHP in this thread, but the database is usually one of the biggest bottlenecks in an application, so it&#039;s probably worth reading this thread.

If you&#039;re interesting in a few of PHP5&#039;s new features, have a look at &quot;PHP5&#039;s new features&quot; (http://www.phpit.net/forums/showthread.php?p=2882) in which the thread starter is very enthusiastically talking about a few new feature of PHP5, such as SPL&#039;s ArrayAccess, __autoload() and more.

Speaking of __autoload(), in &quot;Organizing classes with __autoload()&quot; (http://forums.devnetwork.net/viewtopic.php?t=52943), the thread starter wants to know how to organize his classes and whether or not to use __autoload(). This thread is an excellent discussion on the use of __autoload() and the different ways to organize the classes in your script.

In &quot;Automatic Updates / Check for updates&quot; (http://forums.devnetwork.net/viewtopic.php?t=53550) the thread starter wants to know how to build self-updating script (similar to Windows Update or Mozilla Update) using PHP. Many great replies are given, and some members even give all the requirements necessary, but no actual code has been posted (yet). If you&#039;re interested in the same thing, this is the thread you should read.

And lastly, in &quot;Performance Implications of Type Hinting&quot; (http://forums.devnetwork.net/viewtopic.php?t=52846) the use of type hinting in PHP is discussed. The original thread starter claims type hinting affects performance, which it probably does, but it&#039;s so insignificant compared to the rest (e.g. db queries, loops, etc) that it probably doesn&#039;t matter whether you use type hinting or not. But type hinting may cause problems in other areas as well, and this thread discusses it all.

----------------------------------------------------

Closing Words

That&#039;s it again for this issue, and I hope you enjoyed it. If you have any comments or suggestions, please e-mail me at dennis@phpit.net.

The next issue of the Digest will arrive in your inbox on or around August 29th.

Until then, visit PHPit (http://www.phpit.net) for more PHP articles, and join us at PHPit Forums (http://www.phpit.net/forums/) to talk PHP.

----------------------------------------------------

If you no longer wish to receive the PHPit Digest you can unsubscribe by going to the following URL:
http://www.aspit.net/dada/mail.cgi?f=u&amp;l=phpit&amp;e=[subscriber_email]&amp;p=[pin]</description>
		<content:encoded><![CDATA[<b>The PHPit Digest</b><br />
<i>Weekly PHP news, articles, tips and tricks!</i><br /><br />

Newsletter Archives - <a href="http://digest.phpit.net/">http://digest.phpit.net/</a><br />
Advertising - <a href="http://www.phpit.net/advertising/">http://www.phpit.net/advertising/</a><br />
Contact - <a href="http://www.phpit.net/contact/">http://www.phpit.net/contact/</a><br /><br />

----------------------------------------------------<br /><br />

<b>In This Issue...</b><br /><br />

* Introduction: Editor's Perspective<br />
* Editor's Perspective: character sets, encoding and more<br />
* The Latest PHP Articles From Around The 'Net<br />
* Excerpt: Image manipulation with PHP & the GD library, Part 2<br />
* The Latest PHP Blog Posts From Around The 'Net<br />
* The Latest PHP Discussions From Around The 'Net<br />
* Closing Words<br />

<br />----------------------------------------------------<br /><br />

<b>Introduction: Editor's Perspective</b><br /><br />

Welcome to this new issue of the PHPit Digest, once again filled with the latest news and information on PHP and MySQL.<br />
<br />
This issue comes with an Editor's Perspective again, and this time I talk a bit about character encoding and UTF-8. Even though UTF-8 has existed for many years now, PHP still doesn't support it, and won't support it until PHP6. Read more about this "problem" in the Editor's Perspective.<br />
<br />
The rest of the Digest comes with the usual sections covering the latest PHP articles, blog entries, forum threads and the newest PHPit article.<br />
<br />
<b>Happy Reading!<br />
<br />
Dennis Pallett<br />
dennis@phpit.net </b>

<br /><br />----------------------------------------------------<br /><br />

<b>Editor's Perspective: character sets, encoding and more</b><br /><br />

Character encoding is still a big problem in PHP, mainly because PHP doesn't support any character encoding whatsoever. Can your scripts handle UTF-8 text? Probably not.<br />
<br />
The biggest problem is that PHP simply thinks that 1 byte = 1 character. Therefore, if you have some text that contains multibyte characters, PHP will report the incorrect length. The following example demonstrates this:<br />
<br />
[php]<br />
<? php<br />
echo strlen('Itrntinliztin');<br />
? ><br />
[/php]<br />
<br />
If we count it by hand, we can see that it's 20 characters. But PHP will report 27 characters, because there are several multibyte characters. That's just one of the problems with PHP's lack of UTF-8 support. Another problem is that you can't use the strtolower or strtoupper functions either, because PHP only support the basic characters, and will ignore (or even mangle) all the other characters.<br />
<br />
This means that you can't actually use PHP's string functions, unless you are absolutely certain that there will be no multibyte characters, but these days you can't really be sure of that, because the internet is global and accessed by everyone all over the world.<br />
<br />
Thankfully, Harry Fuecks has posted tons of tips on handling UTF-8 in PHP. In <a href="http://www.sitepoint.com/blogs/2006/08/10/hot-php-utf-8-tips/">his blog entry</a> () he gives several tips and tricks when dealing with UTF-8, and he has even created the <a href="http://sourceforge.net/projects/phputf8">PHP UTF-8</a> () project, which can be used to handle UTF-8 without having to use the mbstring() library.<br />
<br />
PHPWact has also got an <a href="http://www.phpwact.org/php/i18n/charsets">extremely useful page</a> () available where the problem is very clearly explained, and every solution is discussed. This page is a must-read if you're still not sure what the problem is.<br />
<br />
PHP's next major version, PHP6, will be able any character encoding, including UTF-8, but PHP6 is still far away, and it's important that your PHP scripts support Unicode today, especially as the internet becomes more international every day.<br />
<br />
(If you're looking for a history lesson on character sets and encoding, have a look at Joel Spolsky's <a href="http://www.joelonsoftware.com/articles/Unicode.html">"The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets"</a> article).

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Articles From Around The 'Net</b><br /><br />

Let's take a look at the best PHP articles from the past two weeks.<br />
<br />
First up is DevShed's <a href="http://www.devshed.com/c/a/PHP/Introducing-Visitor-Objects-in-PHP-5/">"Introducing Visitor Objects in PHP 5"</a>, in which you are introduced to the Visitor design pattern in PHP5. You will learn what Visitor objects are, and see such an object in action. In the second part, <a href="http://www.devshed.com/c/a/PHP/Expanding-the-Application-Range-of-Visitor-Objects-in-PHP-5/">"Expanding the Application Range of Visitor Objects in PHP 5"</a>, the author shows you more examples of the usage of Visitor Objects in practical examples.<br />
<br />
In <a href="http://www.phphacks.com/content/view/21/33/">"Creating images using GD"</a> you learn how to create images and thumbnails with PHP and the GD library. The author shows you how to enable the GD library and how to generate thumbnails from existing images.<br />
<br />
And if you want to know more about PHP's image functions and the GD library, have a look at <a href="http://www.phpit.net/article/image-manipulation-php-gd-part2/">"Image manipulation with PHP, Part 2"</a>, in which you will learn how to resize images, and watermark them. You will also see how to build a simple online image resizing tool.<br />
<br />
DevShed has also started a new series on implementing the MVC design in PHP. In the first part, <a href="http://www.devshed.com/c/a/PHP/An-Introduction-to-Simulating-the-Model-View-Controller-Schema-in-PHP/">"An Introduction to Simulating the Model-View-Controller Schema in PHP"</a>, you are introduced to the MVC schema, and shown how to construct a basic PHP controller. In the second part, <a href="http://www.devshed.com/c/a/PHP/Building-a-Web-Page-Controller-for-Simulating-the-Model-View-Controller-Schema-in-PHP/">"Building a Web Page Controller for Simulating the Model-View-Controller Schema in PHP"</a>, you will see how to create a web page controller class and a style sheet generator class.<br />
<br />
If you're still somewhat of a beginner, and want to learn more about PHP's class and object support have a look at <a href="http://www.devshed.com/c/a/PHP/Classes-as-PHP-Functions/">"Classes as PHP Functions"</a> or <a href="http://www.tectonic.co.za/view.php?id=1094">"Getting your head around PHP objects"</a>. In both articles you are introduced to the use of objects, methods, and properties.<br />
<br />
And finally, in <a href="http://web.informbank.com/articles/technology/php-office-documents.htm">"How to create Microsoft Office documents on the fly using PHP"</a> you are shown how to create MS Office (Word, Powerpoint, Excel, etc) documents dynamically using PHP.<br />
<br />
<em>To view a complete list of all the latest PHP articles, have a look at <a href="http://www.webdev-articles.com/category/php">Webdev-Articles</a></em>

<br /><br />----------------------------------------------------<br /><br />

<b>Excerpt: Image manipulation with PHP & the GD library, Part 2</b><br /><br />

Welcome to the second part of the "Image manipulation with PHP & the GD library" article series, and in this part we'll take a look at how to resize images, create thumbnails, watermark images and more using PHP's image functions.<br />
<br />
If you haven't read the first part, I recommend you do so before reading this part, because I will talk about several things we've done in the previous part.<br />
<br />
Let's get started with resizing images and creating thumbnails.<br />
<br />
<em><a href="http://www.phpit.net/article/image-manipulation-php-gd-part2/">Click here to read the rest of this article &raquo;</a></em>

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Blog Posts From Around The 'Net</b><br /><br />

Let's take a look at the most interesting blog posts covering PHP and MySQL from the past two weeks.<br />
<br />
<a href="http://www.khankennels.com/blog/index.php/archives/2006/08/13/good-article-on-database-abstraction/">Ligaya Turmelle points</a> to <a href="http://www.xaprb.com/blog/2006/08/13/four-types-of-database-abstraction-layers/">an article on the different types of database abstraction</a>. In this article the author discusses the different types, and discuses the cons and pros of each type.<br />
<br />
In <a href="http://fuzzyblog.com/archives/2006/08/12/sql_calc_found_rows-and-faster-count-alternatives/">"SQL_CALC_FOUND_ROWS and Faster Count(*) Alternatives"</a> Scott Johnson talks about a little MySQL trick that can be used to speed up pagination of results. Usually when doing pagination you first issue a SELECT COUNT(*) query to get the number of results, and then select the actual results you want. In this blog entry Scott gives you another way, that's also faster.<br />
<br />
In the previous issue of the Digest, I pointed to an article by IBM's developerWorks called <a href="http://www-128.ibm.com/developerworks/opensource/library/os-php-dbmistake/?ca=dgr-lnxw97Avoid5PHPerrors">"Five common PHP database problems"</a>. Brian Moon has <a href="http://doughboy.wordpress.com/2006/08/11/mysqlphp-problems/">posted an entry</a> to this article, and posted some of his thoughts on the things mentioned in the article, and his entry is definitely worth reading to learn more about the database problems.<br />
<br />
<a href="http://ilia.ws/index.php?url=archives/121-httpOnly-cookie-flag-support-in-PHP-5.2.html">Ilia Alshanetsky posts</a> about one of PHP 5.2's new features: HttpOnly cookies. HttpOnly cookies are used to prevent JavaScript from reading cookies set in PHP. At the moment this can only be down with the Header() function, and not with the setcookie() function, but in PHP5.2 this will be possible with the setcookie() function.<br />
<br />
As I mentioned in the Editor's Perspective, Harry Fuecks has posted two blog entries on handling UTF-8 in PHP. In his first entry, <a href="http://www.sitepoint.com/blogs/2006/08/09/scripters-utf-8-survival-guide-slides/">"Scripters UTF-8 Survival Guide (slides)"</a>, he provides a pointer to the slides of a recent presentation on this topic. And in the second entry, <a href="http://www.sitepoint.com/blogs/2006/08/10/hot-php-utf-8-tips/">"Hot PHP UTF-8 tips"</a>, he provides a whole list of tips and tricks on handling UTF-8 in PHP.<br />
<br />
If you want to help out the PHP project, have a look at <a href="http://www.khankennels.com/blog/index.php/archives/2006/08/10/25-ways-to-help-out-php/">"25 Ways to help out PHP"</a> which lists 25 different ways of helping the PHP project, ranging from simple bug reports to advocating PHP to actually patching the PHP core.<br />
<br />
And finally, <a href="http://syntux.net/blog/2006/08/08/php5-certification-exam/">Jad Madi writes</a> about his experience taking the new PHP5 Certification Exam, which will be available very soon to everyone. Not a lot of information in his entry, but it still provides some insight into the new exam.

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Discussions From Around The 'Net</b><br /><br />

There have been plenty of great PHP discussions in the past two weeks, so let's take a look and check out the best ones.<br />
<br />
In <a href="http://www.sitepoint.com/forums/showthread.php?t=412061">"APIs"</a> the thread starter wants to know when to re-invent the wheel and create his own libraries and when to use another library / API. As always, opinions differ and many replies are given, but the general reply seems to be that you just have to find a middle ground that you're comfortable with.<br />
<br />
Next, in <a href="http://www.sitepoint.com/forums/showthread.php?t=408530">"Frameworks that are actually used?"</a> Dan Grossman is looking for suggestions for PHP frameworks that are actually used in real live web applications. Although many PHP frameworks have plenty of examples and such, they still lack any real world usage, and that's an important thing. If you're looking for the same thing, have a look at this thread to see which framework Dan eventually chose.<br />
<br />
In <a href="http://www.sitepoint.com/forums/showthread.php?t=407037">"Best Practice - mysql database query"</a> some basics of querying the database is discussed, and the fastest way to do this. Not a lot of PHP in this thread, but the database is usually one of the biggest bottlenecks in an application, so it's probably worth reading this thread.<br />
<br />
If you're interesting in a few of PHP5's new features, have a look at <a href="http://www.phpit.net/forums/showthread.php?p=2882">"PHP5's new features"</a> in which the thread starter is very enthusiastically talking about a few new feature of PHP5, such as SPL's ArrayAccess, __autoload() and more.<br />
<br />
Speaking of __autoload(), in <a href="http://forums.devnetwork.net/viewtopic.php?t=52943">"Organizing classes with __autoload()"</a>, the thread starter wants to know how to organize his classes and whether or not to use __autoload(). This thread is an excellent discussion on the use of __autoload() and the different ways to organize the classes in your script.<br />
<br />
In <a href="http://forums.devnetwork.net/viewtopic.php?t=53550">"Automatic Updates / Check for updates"</a> the thread starter wants to know how to build self-updating script (similar to Windows Update or Mozilla Update) using PHP. Many great replies are given, and some members even give all the requirements necessary, but no actual code has been posted (yet). If you're interested in the same thing, this is the thread you should read.<br />
<br />
And lastly, in <a href="http://forums.devnetwork.net/viewtopic.php?t=52846">"Performance Implications of Type Hinting"</a> the use of type hinting in PHP is discussed. The original thread starter claims type hinting affects performance, which it probably does, but it's so insignificant compared to the rest (e.g. db queries, loops, etc) that it probably doesn't matter whether you use type hinting or not. But type hinting may cause problems in other areas as well, and this thread discusses it all.

<br /><br />----------------------------------------------------<br /><br />

<b>Closing Words</b><br /><br />

That's it again for this issue, and I hope you enjoyed it. If you have any comments or suggestions, please e-mail me at dennis@phpit.net.<br />
<br />
The next issue of the Digest will arrive in your inbox on or around August 29th.<br />
<br />
Until then, visit <a href="http://www.phpit.net">PHPit</a> for more PHP articles, and join us at <a href="http://www.phpit.net/forums/">PHPit Forums</a> to talk PHP.

<br /><br />----------------------------------------------------<br /><br />


If you want to receive the PHPit Digest through e-mail (either in HTML or Plain Text format), you can do so, by subscribing <a href="http://www.aspit.net/dada/mail.cgi?f=list&l=phpit">here</a>.]]></content:encoded>	
	</item>
	<item>
		<title>PHPit Digest #21 - Holiday &amp; a Double issue, image manipulation with PHP...</title>
		<link>http://digest.phpit.net/archives/21/html/</link>
		<pubDate>Tue, 01 Aug 2006 02:00:00 GMT</pubDate>
		<guid>issue21</guid>
		<description>The PHPit Digest
Weekly PHP news, articles, tips and tricks!

Newsletter Archives - http://digest.phpit.net/
Advertising - http://www.phpit.net/advertising/
Contact - http://www.phpit.net/contact/

----------------------------------------------------

In This Issue...

* Introduction: Double Issue
* The Latest PHP Articles From Around The &#039;Net
* Excerpt: Image manipulation with PHP &amp; the GD library, Part 1
* The Latest PHP Blog Posts From Around The &#039;Net
* The Latest PHP Discussions From Around The &#039;Net
* Closing Words

----------------------------------------------------

Introduction: Double Issue

Welcome to this issue of the PHPit Digest, again filled with the latest PHP information, and this time it&#039;s a double issue!

You may or may not have noticed, but the last Digest that you received was about a month ago, which means that I broke the bi-weekly schedule of the Digest, and didn&#039;t send one out two weeks ago. The reason for this is very simple: I was on holiday for two weeks and have mostly been relaxing by the pool. I had no access to the internet or even a computer, and it was great. But now I&#039;m back, and to make up for the absence of the Digest, this issue is a double issue filled with two times as much content.

 Happy Reading!

Dennis  Pallett
dennis@phpit.net 

----------------------------------------------------

The Latest PHP Articles From Around The &#039;Net

There have been an amazing amount of new articles in the past four weeks, so let&#039;s have a look at the best ones.

First of all, there is DevShed&#039;s &quot;Overloading classes in PHP&quot;, which is a three-part article series that shows you how overloading works in PHP. In the first part, &quot;Implementing Property Overloading in PHP 4&quot; (http://www.devshed.com/c/a/PHP/Implementing-Property-Overloading-in-PHP-4/), you are shown how overloading works in PHP4, using the overload extension and the overload() function. Then, in the second part, &quot;Using Method Call Overloading in PHP 4&quot; (http://www.devshed.com/c/a/PHP/Using-Method-Call-Overloading-in-PHP-4/), the author takes a closer look at triggering the &quot;__call()&quot; method, to overload method class. Finally, in the third part, &quot;Overloading Classes in PHP 5&quot; (http://www.devshed.com/c/a/PHP/Overloading-Classes-in-PHP-5/), you will learn about overloading classes in PHP5, which is much easier.

PHPBuilder has published part six of their &quot;Using XML&quot; article series, and in this part (http://www.phpbuilder.com/columns/adam_delves20060719.php3) you are shown how to validate XML with PHP, and the author demonstrates how PHP 5&#039;s XSL extension can be used to validate XML using the Schematron language.

If you want to learn more about using raw sockets in your PHP scripts, have a look at &quot;PHP Sockets Made Easy&quot; (http://www.litfuel.net/tutorials/sockets/sockets.php), written by Jim Plush. In this easy-to-understand tutorial you will learn how to use the raw socket functionality to create a simple server, and complete example code is given, including some helpful screenshots.

DevShed has also started a new article series on the Observer design pattern. In the first part, &quot;An Introduction to the Observer Pattern in PHP&quot; (http://www.devshed.com/c/a/PHP/An-Introduction-to-the-Observer-Pattern-in-PHP/), you are introduced to the Observer pattern, and given a few practical examples to demonstrate the Observer pattern. Then, in the second part, &quot;Developing a Form Validation System with the Observer Pattern in PHP&quot; (http://www.devshed.com/c/a/PHP/Developing-a-Form-Validation-System-with-the-Observer-Pattern-in-PHP/), the author shows you how to build a simple form validation system with the Observer pattern.

And if you want to learn more about validation, have a look at PHPBuilder&#039;s &quot;An introduction to PEAR&#039;s Validate package&quot; (http://www.phpbuilder.com/columns/ian_gilfillan20060630.php3) article, in which you are introduced to the PEAR_Validate package, and its capabilities. Everything is demonstrated with simple examples, and this article is a good introduction to the Validate package.

PHPit has an interesting new tutorial, in which you are shown how to read your POP3 e-mail with PHP. In &quot;Read your e-mail with PHP!&quot; (http://www.phpit.net/article/read-email-php-pop3/) you are given all the code necessary to be able to read your e-mail with PHP. PHPit has also published a new article on image manipulation with PHP and the GD library. In &quot;Image manipulation with PHP &amp; the GD library, Part 1&quot; (http://www.phpit.net/article/image-manipulation-php-gd-part1/) you are taken through the basics of using the GD library.

And lastly, IBM&#039;s developerWorks has also published two new articles. In &quot;PHP encryption for the common man&quot; (http://www-128.ibm.com/developerworks/opensource/library/os-php-encrypt/) you will get an overview of what it means to encrypt and decrypt information, as well as some practical examples involving passwords and other data, using PHP&#039;s built-in functionality. In &quot;Understanding the Zend Framework, Part 2: Model-View-Controller and adding a database&quot; (http://www-128.ibm.com/developerworks/edu/os-dw-os-php-zend2.html) you will see how to use the Zend Framework to create the beginnings of an online feed reader, Chomp, creating a form and adding information to a database while getting to know the MVC pattern.

 To view a complete list of all the latest PHP articles, have a look at Webdev-Articles (http://www.webdev-articles.com/category/php) 

----------------------------------------------------

Excerpt: Image manipulation with PHP &amp; the GD library, Part 1

Image manipulation can be a lot of fun, especially when it&#039;s all done for you by a script. PHP comes with several inbuilt image functions which can be used to do almost anything with images, and that&#039;s exactly what we&#039;ll be looking at.

In this new article series I will take you through most of the common image functions and tasks, and demonstrate everything with live examples. In the first part we will have a look at the basics, and learn how to open images and then display them or save them. We will also see how to write a simple image converter (e.g. JPEG to GIF).

 Click here to read the rest of this article &amp;raquo; (http://www.phpit.net/article/image-manipulation-php-gd-part1/) 

----------------------------------------------------

The Latest PHP Blog Posts From Around The &#039;Net

Even though it&#039;s been a month since the last Digest, not a lot has happened in the PHP world, and there isn&#039;t much news to report. I guess most of us are enjoying the warm summer outside. Nevertheless, let&#039;s have a look at the few interesting entries that have been posted.

SantosJ rants about the PHP compiler in his entry called &quot;PHPc: Compiler Theory and Ranting&quot; (http://www.santosj.name/?p=259). Although it&#039;s mostly a rant about various &quot;bugs&quot; in the PHP compiler, his entry does contain some very interesting and unique suggestions for future PHP versions, like namespaces or the ability to use a symbol for different things. I doubt we&#039;ll see any of these features anytime soon, but they&#039;re definitely worth considering.

Zak Greant points to the slides of Rasmus&#039; OSCON &quot;How To Make Money with PHP&quot; talk (http://talks.php.net/show/oscon06), which is an interesting talk about how to scale your PHP scripts, and how to make money with PHP.

Jason Sweat blogs (http://blog.casey-sweat.us/?p=70) about Jani Taskinen&#039;s (a lead PHP developer) recent departure from the PHP project. His entry doesn&#039;t contain a lot of information about Jani&#039;s departure, but it&#039;s still fairly interesting and provides some background if you haven&#039;t heard about this before. Also about Jani&#039;s departure is a post by Ligaya Turmelle, who posts a &quot;thank you note&quot; to Jani on her blog (http://www.khankennels.com/blog/index.php/archives/2006/08/01/thank-you/), which is a very well-deserved thank you, because Jani has been a major tribute to the PHP project.

E-mail validation is a topic often discussed, and there is still no &quot;ultimate&quot; e-mail validation function. In this entry by SantosJ (http://www.santosj.name/?p=249) he takes a look at a few different solutions for e-mail validation, including the usage of various regular expressions and the Filter extension (http://www.php.net/filter).

SantosJ has also posted an interesting entry about namespaces in PHP. In his entry (http://www.santosj.name/?p=244) he talks about various different implementations of namespaces in PHP, and some of the suggestions are really good, so let&#039;s hope someone on the PHP dev team will read his entry as well.

That&#039;s about it really, and not a lot of other interesting entries have been posted. Guess it&#039;s been pretty quiet lately in &quot;PHP world&quot;. Head on over to Planet PHP (http://www.planet-php.net) for more blog entries.

----------------------------------------------------

The Latest PHP Discussions From Around The &#039;Net

Let&#039;s have a look at the most interesting forum threads on the popular PHP communities.

Always an interesting topic is the usage of globals and how to avoid them. In &quot;How do you avoid using globals/singletons?&quot; (http://www.sitepoint.com/forums/showthread.php?t=406760) the thread starter wants to know exactly how to avoid globals but also how to avoid using Singletons (which are just another way of doing globals really). As usual, the SitePoint community is extremely helpful, and many suggestions are given to help the thread starter out.

In &quot;Advantages of Interfaces and Public Methods and Members&quot; (http://www.sitepoint.com/forums/showthread.php?t=408998) the author wants to know a bit more about a few new PHP5 features, such as the variable modifiers (public/private/protected) and the advantage of using interfaces. If you&#039;re not quite up to speed on these concepts either, have a look at this thread, as the replies give a good overview of what they are.

If you want to know more about scaling PHP scripts, have a look at &quot;and how much do YOU store in the session?&quot; (http://www.sitepoint.com/forums/showthread.php?t=400338), in which the SitePoint members talk about storing frequently-used database information into the sessions to speed up your website. Other solutions to scaling are discussed as well (like using an APC or sqlite in memory) and it&#039;s generally quite an interesting thread about scaling, and could prove useful if you&#039;re having scaling problems as well.

In &quot;Importance of PHP4 Compatibility?&quot; (http://www.sitepoint.com/forums/showthread.php?t=399060) the thread starter wants to know whether it&#039;s still worth maintaining PHP4 compatibility when writing a new PHP script. Opinions differ greatly, but the general consensus seems to be that it&#039;s still worth keeping PHP4 in mind, especially if you&#039;re writing scripts for general distribution.

Did you know that it&#039;s possible to get the current weather with PHP? If not, have a look at &quot;How to get current weather with PHP5&quot; (http://www.phpbuilder.com/board/showthread.php?t=10283087). In this mini-tutorial, posted on the PHPBuilder Forums, you are shown exactly how to use the SimpleXML library to get the current weather from the NOAA web service.

In &quot;PHP/mySQL and VoIP&quot; (http://forums.devnetwork.net/viewtopic.php?t=52730) the DevNetwork forum members talk about using PHP to make automated VoIP calls, using various external applications. Not a lot of PHP code at the moment, and there aren&#039;t many replies yet, but it sounds pretty neat, so this is definitely a thread worth keeping an eye on.

In &quot;Socket Chat Solution?&quot; (http://forums.devnetwork.net/viewtopic.php?t=50188) the thread starter wants to know how to improve the performance of his Ajax/PHP chat script. At the moment his script is executing 3 queries per second per user, which would mean 60 queries per second when there are 20 users in the chatroom, and this obviously not something that you&#039;d want. Many suggestions are given, and the thread slowly moves into a discussion on the usage of PHP&#039;s raw sockets, even though they don&#039;t really help out in this case. If you&#039;re interesting in building your own chat script, have a look at this thread.

If you&#039;ve ever wondered how to display times in your local timezone, instead of the server&#039;s timezone, have a look at &quot;local time, not server time&quot; (http://www.phpit.net/forums/showthread.php?p=2683), in which the thread starter wants to know exactly how to do that. Not a lot of replies so far, but the thread already contains some useful advice on doing this.

And lastly, if you want to know how to write your own (simple) search engine in PHP, read &quot;Search Engine Design with PHP&quot; (http://forums.devnetwork.net/viewtopic.php?t=50617). The thread starter has been assigned to create a search engine, and needs some help with writing it, with many forum members jumping in and helping out.

----------------------------------------------------

Closing Words

That&#039;s it again for this issue, and I hope you enjoyed reading it. If you have any comments or suggestions, please e-mail me at dennis@phpit.net.

The next issue of the Digest will arrive in your inbox on or around August 15th.

Until then, visit PHPit (http://www.phpit.net) for more PHP articles and join us at PHPit Forums (http://www.phpit.net/forums/) to talk PHP.


----------------------------------------------------

If you no longer wish to receive the PHPit Digest you can unsubscribe by going to the following URL:
http://www.aspit.net/dada/mail.cgi?f=u&amp;l=phpit&amp;e=[subscriber_email]&amp;p=[pin]</description>
		<content:encoded><![CDATA[<b>The PHPit Digest</b><br />
<i>Weekly PHP news, articles, tips and tricks!</i><br /><br />

Newsletter Archives - <a href="http://digest.phpit.net/">http://digest.phpit.net/</a><br />
Advertising - <a href="http://www.phpit.net/advertising/">http://www.phpit.net/advertising/</a><br />
Contact - <a href="http://www.phpit.net/contact/">http://www.phpit.net/contact/</a><br /><br />

----------------------------------------------------<br /><br />

<b>In This Issue...</b><br /><br />

* Introduction: Double Issue<br />
* The Latest PHP Articles From Around The 'Net<br />
* Excerpt: Image manipulation with PHP & the GD library, Part 1<br />
* The Latest PHP Blog Posts From Around The 'Net<br />
* The Latest PHP Discussions From Around The 'Net<br />
* Closing Words<br />

<br />----------------------------------------------------<br /><br />

<b>Introduction: Double Issue</b><br /><br />

Welcome to this issue of the PHPit Digest, again filled with the latest PHP information, and this time it's a double issue!<br />
<br />
You may or may not have noticed, but the last Digest that you received was about a month ago, which means that I broke the bi-weekly schedule of the Digest, and didn't send one out two weeks ago. The reason for this is very simple: I was on holiday for two weeks and have mostly been relaxing by the pool. I had no access to the internet or even a computer, and it was great. But now I'm back, and to make up for the absence of the Digest, this issue is a double issue filled with two times as much content.<br />
<br />
<b>Happy Reading!<br />
<br />
Dennis  Pallett<br />
dennis@phpit.net</b>

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Articles From Around The 'Net</b><br /><br />

There have been an amazing amount of new articles in the past four weeks, so let's have a look at the best ones.<br />
<br />
First of all, there is DevShed's "Overloading classes in PHP", which is a three-part article series that shows you how overloading works in PHP. In the first part, <a href="http://www.devshed.com/c/a/PHP/Implementing-Property-Overloading-in-PHP-4/">"Implementing Property Overloading in PHP 4"</a>, you are shown how overloading works in PHP4, using the overload extension and the overload() function. Then, in the second part, <a href="http://www.devshed.com/c/a/PHP/Using-Method-Call-Overloading-in-PHP-4/">"Using Method Call Overloading in PHP 4"</a>, the author takes a closer look at triggering the "__call()" method, to overload method class. Finally, in the third part, <a href="http://www.devshed.com/c/a/PHP/Overloading-Classes-in-PHP-5/">"Overloading Classes in PHP 5"</a>, you will learn about overloading classes in PHP5, which is much easier.<br />
<br />
PHPBuilder has published part six of their "Using XML" article series, and in <a href="http://www.phpbuilder.com/columns/adam_delves20060719.php3">this part</a> you are shown how to validate XML with PHP, and the author demonstrates how PHP 5's XSL extension can be used to validate XML using the Schematron language.<br />
<br />
If you want to learn more about using raw sockets in your PHP scripts, have a look at <a href="http://www.litfuel.net/tutorials/sockets/sockets.php">"PHP Sockets Made Easy"</a>, written by Jim Plush. In this easy-to-understand tutorial you will learn how to use the raw socket functionality to create a simple server, and complete example code is given, including some helpful screenshots.<br />
<br />
DevShed has also started a new article series on the Observer design pattern. In the first part, <a href="http://www.devshed.com/c/a/PHP/An-Introduction-to-the-Observer-Pattern-in-PHP/">"An Introduction to the Observer Pattern in PHP"</a>, you are introduced to the Observer pattern, and given a few practical examples to demonstrate the Observer pattern. Then, in the second part, <a href="http://www.devshed.com/c/a/PHP/Developing-a-Form-Validation-System-with-the-Observer-Pattern-in-PHP/">"Developing a Form Validation System with the Observer Pattern in PHP"</a>, the author shows you how to build a simple form validation system with the Observer pattern.<br />
<br />
And if you want to learn more about validation, have a look at PHPBuilder's <a href="http://www.phpbuilder.com/columns/ian_gilfillan20060630.php3">"An introduction to PEAR's Validate package"</a> article, in which you are introduced to the PEAR_Validate package, and its capabilities. Everything is demonstrated with simple examples, and this article is a good introduction to the Validate package.<br />
<br />
PHPit has an interesting new tutorial, in which you are shown how to read your POP3 e-mail with PHP. In <a href="http://www.phpit.net/article/read-email-php-pop3/">"Read your e-mail with PHP!"</a> you are given all the code necessary to be able to read your e-mail with PHP. PHPit has also published a new article on image manipulation with PHP and the GD library. In <a href="http://www.phpit.net/article/image-manipulation-php-gd-part1/">"Image manipulation with PHP & the GD library, Part 1"</a> you are taken through the basics of using the GD library.<br />
<br />
And lastly, IBM's developerWorks has also published two new articles. In <a href="http://www-128.ibm.com/developerworks/opensource/library/os-php-encrypt/">"PHP encryption for the common man"</a> you will get an overview of what it means to encrypt and decrypt information, as well as some practical examples involving passwords and other data, using PHP's built-in functionality. In <a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-zend2.html">"Understanding the Zend Framework, Part 2: Model-View-Controller and adding a database"</a> you will see how to use the Zend Framework to create the beginnings of an online feed reader, Chomp, creating a form and adding information to a database while getting to know the MVC pattern.<br />
<br />
<em>To view a complete list of all the latest PHP articles, have a look at <a href="http://www.webdev-articles.com/category/php">Webdev-Articles</a></em>

<br /><br />----------------------------------------------------<br /><br />

<b>Excerpt: Image manipulation with PHP & the GD library, Part 1</b><br /><br />

Image manipulation can be a lot of fun, especially when it's all done for you by a script. PHP comes with several inbuilt image functions which can be used to do almost anything with images, and that's exactly what we'll be looking at.<br />
<br />
In this new article series I will take you through most of the common image functions and tasks, and demonstrate everything with live examples. In the first part we will have a look at the basics, and learn how to open images and then display them or save them. We will also see how to write a simple image converter (e.g. JPEG to GIF).<br />
<br />
<em><a href="http://www.phpit.net/article/image-manipulation-php-gd-part1/">Click here to read the rest of this article &raquo;</a></em>

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Blog Posts From Around The 'Net</b><br /><br />

Even though it's been a month since the last Digest, not a lot has happened in the PHP world, and there isn't much news to report. I guess most of us are enjoying the warm summer outside. Nevertheless, let's have a look at the few interesting entries that have been posted.<br />
<br />
SantosJ rants about the PHP compiler in his entry called <a href="http://www.santosj.name/?p=259">"PHPc: Compiler Theory and Ranting"</a>. Although it's mostly a rant about various "bugs" in the PHP compiler, his entry does contain some very interesting and unique suggestions for future PHP versions, like namespaces or the ability to use a symbol for different things. I doubt we'll see any of these features anytime soon, but they're definitely worth considering.<br />
<br />
Zak Greant points to the slides of Rasmus' OSCON <a href="http://talks.php.net/show/oscon06">"How To Make Money with PHP" talk</a>, which is an interesting talk about how to scale your PHP scripts, and how to make money with PHP.<br />
<br />
<a href="http://blog.casey-sweat.us/?p=70">Jason Sweat blogs</a> about Jani Taskinen's (a lead PHP developer) recent departure from the PHP project. His entry doesn't contain a lot of information about Jani's departure, but it's still fairly interesting and provides some background if you haven't heard about this before. Also about Jani's departure is a post by Ligaya Turmelle, who posts a <a href="http://www.khankennels.com/blog/index.php/archives/2006/08/01/thank-you/">"thank you note" to Jani on her blog</a>, which is a very well-deserved thank you, because Jani has been a major tribute to the PHP project.<br />
<br />
E-mail validation is a topic often discussed, and there is still no "ultimate" e-mail validation function. <a href="http://www.santosj.name/?p=249">In this entry by SantosJ</a> he takes a look at a few different solutions for e-mail validation, including the usage of various regular expressions and the <a href="http://www.php.net/filter">Filter extension</a>.<br />
<br />
SantosJ has also posted an interesting entry about namespaces in PHP. <a href="http://www.santosj.name/?p=244">In his entry</a> he talks about various different implementations of namespaces in PHP, and some of the suggestions are really good, so let's hope someone on the PHP dev team will read his entry as well.<br />
<br />
That's about it really, and not a lot of other interesting entries have been posted. Guess it's been pretty quiet lately in "PHP world". Head on over to <a href="http://www.planet-php.net">Planet PHP</a> for more blog entries.

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Discussions From Around The 'Net</b><br /><br />

Let's have a look at the most interesting forum threads on the popular PHP communities.<br />
<br />
Always an interesting topic is the usage of globals and how to avoid them. In <a href="http://www.sitepoint.com/forums/showthread.php?t=406760">"How do you avoid using globals/singletons?"</a> the thread starter wants to know exactly how to avoid globals but also how to avoid using Singletons (which are just another way of doing globals really). As usual, the SitePoint community is extremely helpful, and many suggestions are given to help the thread starter out.<br />
<br />
In <a href="http://www.sitepoint.com/forums/showthread.php?t=408998">"Advantages of Interfaces and Public Methods and Members"</a> the author wants to know a bit more about a few new PHP5 features, such as the variable modifiers (public/private/protected) and the advantage of using interfaces. If you're not quite up to speed on these concepts either, have a look at this thread, as the replies give a good overview of what they are.<br />
<br />
If you want to know more about scaling PHP scripts, have a look at <a href="http://www.sitepoint.com/forums/showthread.php?t=400338">"and how much do YOU store in the session?"</a>, in which the SitePoint members talk about storing frequently-used database information into the sessions to speed up your website. Other solutions to scaling are discussed as well (like using an APC or sqlite in memory) and it's generally quite an interesting thread about scaling, and could prove useful if you're having scaling problems as well.<br />
<br />
In <a href="http://www.sitepoint.com/forums/showthread.php?t=399060">"Importance of PHP4 Compatibility?"</a> the thread starter wants to know whether it's still worth maintaining PHP4 compatibility when writing a new PHP script. Opinions differ greatly, but the general consensus seems to be that it's still worth keeping PHP4 in mind, especially if you're writing scripts for general distribution.<br />
<br />
Did you know that it's possible to get the current weather with PHP? If not, have a look at <a href="http://www.phpbuilder.com/board/showthread.php?t=10283087">"How to get current weather with PHP5"</a>. In this mini-tutorial, posted on the PHPBuilder Forums, you are shown exactly how to use the SimpleXML library to get the current weather from the NOAA web service.<br />
<br />
In <a href="http://forums.devnetwork.net/viewtopic.php?t=52730">"PHP/mySQL and VoIP"</a> the DevNetwork forum members talk about using PHP to make automated VoIP calls, using various external applications. Not a lot of PHP code at the moment, and there aren't many replies yet, but it sounds pretty neat, so this is definitely a thread worth keeping an eye on.<br />
<br />
In <a href="http://forums.devnetwork.net/viewtopic.php?t=50188">"Socket Chat Solution?"</a> the thread starter wants to know how to improve the performance of his Ajax/PHP chat script. At the moment his script is executing 3 queries per second per user, which would mean 60 queries per second when there are 20 users in the chatroom, and this obviously not something that you'd want. Many suggestions are given, and the thread slowly moves into a discussion on the usage of PHP's raw sockets, even though they don't really help out in this case. If you're interesting in building your own chat script, have a look at this thread.<br />
<br />
If you've ever wondered how to display times in your local timezone, instead of the server's timezone, have a look at <a href="http://www.phpit.net/forums/showthread.php?p=2683">"local time, not server time"</a>, in which the thread starter wants to know exactly how to do that. Not a lot of replies so far, but the thread already contains some useful advice on doing this.<br />
<br />
And lastly, if you want to know how to write your own (simple) search engine in PHP, read <a href="http://forums.devnetwork.net/viewtopic.php?t=50617">"Search Engine Design with PHP"</a>. The thread starter has been assigned to create a search engine, and needs some help with writing it, with many forum members jumping in and helping out.

<br /><br />----------------------------------------------------<br /><br />

<b>Closing Words</b><br /><br />

That's it again for this issue, and I hope you enjoyed reading it. If you have any comments or suggestions, please e-mail me at dennis@phpit.net.<br />
<br />
The next issue of the Digest will arrive in your inbox on or around August 15th.<br />
<br />
Until then, visit <a href="http://www.phpit.net">PHPit</a> for more PHP articles and join us at <a href="http://www.phpit.net/forums/">PHPit Forums</a> to talk PHP.<br />


<br /><br />----------------------------------------------------<br /><br />


If you want to receive the PHPit Digest through e-mail (either in HTML or Plain Text format), you can do so, by subscribing <a href="http://www.aspit.net/dada/mail.cgi?f=list&l=phpit">here</a>.]]></content:encoded>	
	</item>
	<item>
		<title>PHPit Digest #20 - Static methods?, using globals, article PDF's...</title>
		<link>http://digest.phpit.net/archives/20/html/</link>
		<pubDate>Tue, 04 Jul 2006 02:00:00 GMT</pubDate>
		<guid>issue20</guid>
		<description>The PHPit Digest
Weekly PHP news, articles, tips and tricks!

Newsletter Archives - http://digest.phpit.net/
Advertising - http://www.phpit.net/advertising/
Contact - http://www.phpit.net/contact/

----------------------------------------------------

In This Issue...

* Introduction: It&#039;s so hot!
* The Latest PHP Articles From Around The &#039;Net
* Excerpt: Using globals in PHP
* The Latest PHP Blog Posts From Around The &#039;Net
* Did you know?
* The Latest PHP Discussions From Around The &#039;Net
* Closing Words

----------------------------------------------------

Introduction: It&#039;s so hot!

Welcome to this issue of the PHPit Digest, and as usual it&#039;s filled with plenty of PHP information, news and more!

Not a lot of things to say really, because not a lot has happened in the past two weeks. Summer has really started here with temperatures over 30 C (86 F) so I&#039;ve taken it easier lately, and the next two weeks look very summery as well, so don&#039;t expect too much in the next Digest either.

For now, enjoy the usual sections as there are tons of great articles, blog posts and forum threads, and I&#039;m sure you&#039;ll enjoy reading most of the content I&#039;ve highlighted.

 Happy Reading! 

 Dennis Pallett
dennis@phpit.net 

----------------------------------------------------

The Latest PHP Articles From Around The &#039;Net

Somewhat surprising but there haven&#039;t been a lot of new articles in the past two weeks, although there have been a few really good one&#039;s, so let&#039;s have a look at what&#039;s been published.

First up is &quot;Working with MySQL and Sessions to Serialize Objects in PHP&quot; (http://www.devshed.com/c/a/PHP/Working-with-MySQL-and-Sessions-to-Serialize-Objects-in-PHP/) which is the third and final part of DevShed&#039;s &quot;Serializing Objects&quot; article series, and in this part you are shown how to use MySQL as the Session storage handler, and how to serialize objects to a MySQL database.

&quot;Craft a Webmail interface for PHP applications&quot; (http://www-128.ibm.com/developerworks/edu/os-dw-os-php-webmail.html?ca=drs-) will show you how to create a webmail application for your visitors. Unfortunately, the article is behind a (free) login, but it&#039;s worth registering for.

SitePoint has published a new article in which you are shown how to create images on-the-fly using the ImageMagick library, instead of the more common GD library. In the article (http://www.sitepoint.com/article/dynamic-images-imagemagick) the author takes you through all the steps to create a basic image, and gives you all the code necessary. Unfortunately, any advanced use of the library isn&#039;t demonstrated, which is a shame really.

In &quot;Using globals in PHP&quot; (http://www.phpit.net/article/using-globals-php/) you are introduced to the Singleton and Registry design patterns to avoid the use of global variables. I&#039;ve had much success with the Registry design pattern, and once you understand it you&#039;ll never have it any other way.

DevShed has also published part two in their &quot;Using mysqli with PHP 5&quot; (http://www.devshed.com/c/a/MySQL/Implementing-the-commit-and-rollback-Methods-with-mysqli-and-PHP-5/) article series. In this part the author will show you how to implement the commit() and rollback() methods of the mysqli extension, which can be used to do a transaction with MySQL. 

If you want to know more about the Zend Framework, have a look at &quot;Understanding the Zend Framework, Part 1: The basics&quot; (http://www-128.ibm.com/developerworks/library/os-php-zend1/), in which the author gives you a basic introduction to the Zend Framework. This is the first part of a new nine-part article series, in which you will use the Zend Framework to build an Ajax-enabled RSS reader.

In &quot;Object-Oriented Features New To PHP5&quot; (http://www.phpbuilder.com/columns/object_oriented_php20060620.php3), which is an excerpt from Object-Oriented PHP: Concepts, Techniques, and Code, you will read about several new OOP features of PHP5, such as access modifiers (public/private/protected), exceptions, and more. Not really anything new in this article, but if you still don&#039;t know about PHP5&#039;s new OOP features, this article clearly outlines it all for you.

Lastly, in &quot;Simple Optimization for PHP and MySQL&quot; (http://www.dublish.com/articles/10.html) you will find multiple tips and tricks to optimize and improve performance of your PHP scripts and MySQL server. Most of the tips presented in this article are very simple to implement, although some of them are fairly useless (in my opinion).

 To view a complete list of all the latest PHP articles, have a look at Webdev-Articles (http://www.webdev-articles.com/category/php) 

----------------------------------------------------

Excerpt: Using globals in PHP

Whenever you&#039;re developing a new large-scale PHP script, you&#039;re bound to use global variables, since some data needs to be used by multiple parts of your script. Good examples of global data are script settings, database connections, user credentials and more. There are many ways of making this data global, but the most commonly used way is to use the global keyword, which we will explore later on in this article.

The only problem with the global keyword, and any global data for that matter, is that&#039;s it&#039;s actually a very bad way of programming, and usually tends to lead to bigger problems later on. The reason for this is that global data ties all the separate parts of your script together, and often if you make a change in one part, something else will break in another part. If you have more than a few global variables, you&#039;re whole script will eventually become a big kludge of unmaintainable code.

That&#039;s why this article will show you how to prevent this by using various techniques and design patterns. But first, let&#039;s have a look at the global keyword and how it works.

 Click here to read the rest of this article &amp;raquo; (http://www.phpit.net/article/using-globals-php/) 

----------------------------------------------------

The Latest PHP Blog Posts From Around The &#039;Net

Let&#039;s have a look at the best PHP blog posts of the past two weeks.

Christopher Kunz gives us a book tip (http://www.christopher-kunz.de/serendipity/archives/99-Book-tip-Building-Scalable-Web-Sites.html) about &quot;Building Scalable Web Sites&quot;, which according to him is a must-read if you&#039;re looking to build scalable websites, and the book is well worth the money.

In &quot;Extending Zend_Controller_Action&quot; (http://blog.wolff-hamburg.de/archives/5-Extending-Zend_Controller_Action.html) Markus Wolff shows you how to use the Zend Controller class of the Zend Framework and how to extend it to use the inbuilt Zend_View class. A neat little tutorial on the Zend Framework, and very useful if you&#039;re planning on using the ZF for your website.

Matthew Weier O&#039;Phinney mentions (http://weierophinney.net/matthew/archives/122-Zend-is-looking-for-PHP-Developers.html) that Zend is looking for some PHP developers to join their web development team. Seems like a great position to me, and I highly encourage people to apply. Read the entry for more information.

In &quot;Bug or feature? - Beature&quot; (http://wolfram.kriesing.de/blog/index.php/2006/bug-or-feature-beature) Wolfram Kriesing talks about a bug, or what some call a feature, in PHP which is a bit dubious. Read his entry for all the details, but let me just say that I&#039;ve encountered this &quot;feature&quot; before and it&#039;s highly annoying and I definitely consider it to be a bug.

In another entry by Markus Wolff (http://blog.wolff-hamburg.de/archives/4-Zend-Framework-CLA.html) he wonders aloud whether the CLA you need to sign before you can work on the Zend Framework is really necessary. His entry has quite a lot of comments, and even Andi Gutmans himself has replied with the reasons why a CLA is necessary. Very interesting entry if you&#039;ve wondered the same thing.

Jo Brunner has posted an extensive tutorial on speeding up your website on the ThinkPHP blog. In the entry (http://blog.thinkphp.de/archives/121-guid.html#extended) you will be shown how to use lighthttpd, memcached, FastCGI and other applications to make your website run as fast as possible.  The entry comes with full installation instructions, config files and even some example PHP code to demonstrate the use of MySQL 5&#039;s stored procedures and memcached. A very useful entry if you want to get top-notch performance from your website.

The ThinkPHP blog also has another interesting entry (http://blog.thinkphp.de/archives/120-Virtual-Data-Grid-becoming-reality-soon.html) on the &quot;Virtual Data Grid&quot;, which is a new tool by TurboAjax.com. This virtual data grid looks really neat, and a demo can be viewed by clicking here (http://www.turboajax.com/demo/TurboDataGrid_Dynamic.html). 

Quite a lot of great blog posts this time, and there are plenty more on Planet PHP (http://www.planet-php.net), so don&#039;t forget to visit or subscribe to their RSS feed (http://www.planet-php.net/rdf/).

----------------------------------------------------

Did you know?

Did you know that it&#039;s now possible to download articles on PHPit (http://www.phpit.net) in PDF format?

When viewing an article, just click on the PDF icon on the right-hand side (below the article index). This allows you to download the article to your desktop, and read it later on or even print it out.

You can also share downloaded articles with other people, or put it on your website, as long as you don&#039;t change the PDF.

----------------------------------------------------

The Latest PHP Discussions From Around The &#039;Net

It&#039;s time again to look at the best PHP forum topics and posts in the past two weeks. Let&#039;s see what the PHP community has been talking about.

In &quot;When does one use Static Methods/Variables/Classes?&quot; (http://www.sitepoint.com/forums/showthread.php?t=397829) the thread starter wants to know when it&#039;s okay to use static class methods and when it&#039;s not. Not surprisingly, there isn&#039;t really a good answer to this, and the thread turns into a discussion with many different opinions.

Related to this thread is &quot;Why all the static use of classes?&quot; (http://framework.zend.com/wiki/spaces/viewthread.action?key=ZFMLGEN&amp;id=954). This thread, part of the Zend Framework mailing list, is about the excessive use of static methods in the Zend Framework, and the author would like to know why. Just like the previous thread, a discussion starts on the proper use of static classes, and no real conclusion is reached. A very interesting discussion nonetheless.

In &quot;ApplicationController revised&quot; (http://www.sitepoint.com/forums/showthread.php?t=393242) the author, Ezku, posts his idea for an ApplicationController, and asks for feedback from other members. Not a lot of response so far, but a few posts down in the thread forum member kyberfabrikken posts about his own framework, and shows how his ApplicationController works, and it&#039;s a very fascinating post, and definitely worth reading.

Whilst we&#039;re on the subject of controllers, in &quot;Front Controller Delegating to Page Controller&quot; (http://www.sitepoint.com/forums/showthread.php?t=395308) the author wants to know if his current Front Controller implementation is solid enough, or if it needs to be improved in some areas. General feedback in the thread seems to be that it&#039;s fairly good, although a few suggestions are offered.

In &quot;Superglobal wrapper object help&quot; (http://www.sitepoint.com/forums/showthread.php?t=395461) the SitePoint members discuss the use of a superglobal or request wrapper, and the cons of pros of using such a wrapper. Some argue against it, since isn&#039;t really necessary, but others disagree, and argue that superglobals are still globals and should therefore be avoided. 

If you&#039;re looking for some helper scripts for the SimpleTest library, have a look at &quot;Little SimpleTest helper&quot; (http://www.sitepoint.com/forums/showthread.php?t=395209), where several members, including me, post their helper scripts for SimpleTest, like a unit test manager, a factory class for mock objects, a run_test function and more. Not a lot of information or discussion in this thread, but plenty of useful code snippets!

In &quot;Help choosing a format for external language files&quot; (http://www.sitepoint.com/forums/showthread.php?t=395035) the thread starter is looking for suggestions on the type of file he should use as his language files. Many suggestions are given, such as INI, XML, YAML and more. Personally, I&#039;d use XML myself since it&#039;s the easiest to use and still very flexible, but INI files are a good choice as well.

And finally, in &quot;MVC implementations&quot; (http://www.phpit.net/forums/showthread.php?p=2345) the thread starter kicks off a live application design session, and will be creating an MVC implementation from scratch together with other forum members. Not a lot of input yet, but hopefully there will be soon. And what are you waiting for? Come and join the fun!

----------------------------------------------------

Closing Words

That&#039;s it again for this issue, and I hope you enjoyed it. If you have any comments or feedback, please e-mail me at dennis@phpit.net.

The next issue of the Digest will arrive in your inbox on or around July 18th.

Until then, visit PHPit (http://www.phpit.net) for more PHP articles, and join us at PHPit Forums (http://www.phpit.net/forums/) for more PHP discussion.


----------------------------------------------------

If you no longer wish to receive the PHPit Digest you can unsubscribe by going to the following URL:
http://www.aspit.net/dada/mail.cgi?f=u&amp;l=phpit&amp;e=[subscriber_email]&amp;p=[pin]</description>
		<content:encoded><![CDATA[<b>The PHPit Digest</b><br />
<i>Weekly PHP news, articles, tips and tricks!</i><br /><br />

Newsletter Archives - <a href="http://digest.phpit.net/">http://digest.phpit.net/</a><br />
Advertising - <a href="http://www.phpit.net/advertising/">http://www.phpit.net/advertising/</a><br />
Contact - <a href="http://www.phpit.net/contact/">http://www.phpit.net/contact/</a><br /><br />

----------------------------------------------------<br /><br />

<b>In This Issue...</b><br /><br />

* Introduction: It's so hot!<br />
* The Latest PHP Articles From Around The 'Net<br />
* Excerpt: Using globals in PHP<br />
* The Latest PHP Blog Posts From Around The 'Net<br />
* Did you know?<br />
* The Latest PHP Discussions From Around The 'Net<br />
* Closing Words<br />

<br />----------------------------------------------------<br /><br />

<b>Introduction: It's so hot!</b><br /><br />

Welcome to this issue of the PHPit Digest, and as usual it's filled with plenty of PHP information, news and more!<br />
<br />
Not a lot of things to say really, because not a lot has happened in the past two weeks. Summer has really started here with temperatures over 30 C (86 F) so I've taken it easier lately, and the next two weeks look very summery as well, so don't expect too much in the next Digest either.<br />
<br />
For now, enjoy the usual sections as there are tons of great articles, blog posts and forum threads, and I'm sure you'll enjoy reading most of the content I've highlighted.<br />
<br />
<strong>Happy Reading!</strong><br />
<br />
<b>Dennis Pallett<br />
dennis@phpit.net</b>

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Articles From Around The 'Net</b><br /><br />

Somewhat surprising but there haven't been a lot of new articles in the past two weeks, although there have been a few really good one's, so let's have a look at what's been published.<br />
<br />
First up is <a href="http://www.devshed.com/c/a/PHP/Working-with-MySQL-and-Sessions-to-Serialize-Objects-in-PHP/">"Working with MySQL and Sessions to Serialize Objects in PHP"</a> which is the third and final part of DevShed's "Serializing Objects" article series, and in this part you are shown how to use MySQL as the Session storage handler, and how to serialize objects to a MySQL database.<br />
<br />
<a href="http://www-128.ibm.com/developerworks/edu/os-dw-os-php-webmail.html?ca=drs-">"Craft a Webmail interface for PHP applications"</a> will show you how to create a webmail application for your visitors. Unfortunately, the article is behind a (free) login, but it's worth registering for.<br />
<br />
SitePoint has published a new article in which you are shown how to create images on-the-fly using the ImageMagick library, instead of the more common GD library. <a href="http://www.sitepoint.com/article/dynamic-images-imagemagick">In the article</a> the author takes you through all the steps to create a basic image, and gives you all the code necessary. Unfortunately, any advanced use of the library isn't demonstrated, which is a shame really.<br />
<br />
In <a href="http://www.phpit.net/article/using-globals-php/">"Using globals in PHP"</a> you are introduced to the Singleton and Registry design patterns to avoid the use of global variables. I've had much success with the Registry design pattern, and once you understand it you'll never have it any other way.<br />
<br />
DevShed has also published part two in their <a href="http://www.devshed.com/c/a/MySQL/Implementing-the-commit-and-rollback-Methods-with-mysqli-and-PHP-5/">"Using mysqli with PHP 5"</a> article series. In this part the author will show you how to implement the commit() and rollback() methods of the mysqli extension, which can be used to do a transaction with MySQL. <br />
<br />
If you want to know more about the Zend Framework, have a look at <a href="http://www-128.ibm.com/developerworks/library/os-php-zend1/">"Understanding the Zend Framework, Part 1: The basics"</a>, in which the author gives you a basic introduction to the Zend Framework. This is the first part of a new nine-part article series, in which you will use the Zend Framework to build an Ajax-enabled RSS reader.<br />
<br />
In <a href="http://www.phpbuilder.com/columns/object_oriented_php20060620.php3">"Object-Oriented Features New To PHP5"</a>, which is an excerpt from Object-Oriented PHP: Concepts, Techniques, and Code, you will read about several new OOP features of PHP5, such as access modifiers (public/private/protected), exceptions, and more. Not really anything new in this article, but if you still don't know about PHP5's new OOP features, this article clearly outlines it all for you.<br />
<br />
Lastly, in <a href="http://www.dublish.com/articles/10.html">"Simple Optimization for PHP and MySQL"</a> you will find multiple tips and tricks to optimize and improve performance of your PHP scripts and MySQL server. Most of the tips presented in this article are very simple to implement, although some of them are fairly useless (in my opinion).<br />
<br />
<em>To view a complete list of all the latest PHP articles, have a look at <a href="http://www.webdev-articles.com/category/php">Webdev-Articles</a></em>

<br /><br />----------------------------------------------------<br /><br />

<b>Excerpt: Using globals in PHP</b><br /><br />

Whenever you're developing a new large-scale PHP script, you're bound to use global variables, since some data needs to be used by multiple parts of your script. Good examples of global data are script settings, database connections, user credentials and more. There are many ways of making this data global, but the most commonly used way is to use the global keyword, which we will explore later on in this article.<br />
<br />
The only problem with the global keyword, and any global data for that matter, is that's it's actually a very bad way of programming, and usually tends to lead to bigger problems later on. The reason for this is that global data ties all the separate parts of your script together, and often if you make a change in one part, something else will break in another part. If you have more than a few global variables, you're whole script will eventually become a big kludge of unmaintainable code.<br />
<br />
That's why this article will show you how to prevent this by using various techniques and design patterns. But first, let's have a look at the global keyword and how it works.<br />
<br />
<em><a href="http://www.phpit.net/article/using-globals-php/">Click here to read the rest of this article &raquo;</a></em>

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Blog Posts From Around The 'Net</b><br /><br />

Let's have a look at the best PHP blog posts of the past two weeks.<br />
<br />
Christopher Kunz <a href="http://www.christopher-kunz.de/serendipity/archives/99-Book-tip-Building-Scalable-Web-Sites.html">gives us a book tip</a> about "Building Scalable Web Sites", which according to him is a must-read if you're looking to build scalable websites, and the book is well worth the money.<br />
<br />
In <a href="http://blog.wolff-hamburg.de/archives/5-Extending-Zend_Controller_Action.html">"Extending Zend_Controller_Action"</a> Markus Wolff shows you how to use the Zend Controller class of the Zend Framework and how to extend it to use the inbuilt Zend_View class. A neat little tutorial on the Zend Framework, and very useful if you're planning on using the ZF for your website.<br />
<br />
<a href="http://weierophinney.net/matthew/archives/122-Zend-is-looking-for-PHP-Developers.html">Matthew Weier O'Phinney mentions</a> that Zend is looking for some PHP developers to join their web development team. Seems like a great position to me, and I highly encourage people to apply. Read the entry for more information.<br />
<br />
In <a href="http://wolfram.kriesing.de/blog/index.php/2006/bug-or-feature-beature">"Bug or feature? - Beature"</a> Wolfram Kriesing talks about a bug, or what some call a feature, in PHP which is a bit dubious. Read his entry for all the details, but let me just say that I've encountered this "feature" before and it's highly annoying and I definitely consider it to be a bug.<br />
<br />
In <a href="http://blog.wolff-hamburg.de/archives/4-Zend-Framework-CLA.html">another entry by Markus Wolff</a> he wonders aloud whether the CLA you need to sign before you can work on the Zend Framework is really necessary. His entry has quite a lot of comments, and even Andi Gutmans himself has replied with the reasons why a CLA is necessary. Very interesting entry if you've wondered the same thing.<br />
<br />
Jo Brunner has posted an extensive tutorial on speeding up your website on the ThinkPHP blog. <a href="http://blog.thinkphp.de/archives/121-guid.html#extended">In the entry</a> you will be shown how to use lighthttpd, memcached, FastCGI and other applications to make your website run as fast as possible.  The entry comes with full installation instructions, config files and even some example PHP code to demonstrate the use of MySQL 5's stored procedures and memcached. A very useful entry if you want to get top-notch performance from your website.<br />
<br />
The ThinkPHP blog also has <a href="http://blog.thinkphp.de/archives/120-Virtual-Data-Grid-becoming-reality-soon.html">another interesting entry</a> on the "Virtual Data Grid", which is a new tool by TurboAjax.com. This virtual data grid looks really neat, and a demo can be <a href="http://www.turboajax.com/demo/TurboDataGrid_Dynamic.html">viewed by clicking here</a>. <br />
<br />
Quite a lot of great blog posts this time, and there are plenty more on <a href="http://www.planet-php.net">Planet PHP</a>, so don't forget to visit or <a href="http://www.planet-php.net/rdf/">subscribe to their RSS feed</a>.

<br /><br />----------------------------------------------------<br /><br />

<b>Did you know?</b><br /><br />

Did you know that it's now possible to download articles on <a href="http://www.phpit.net">PHPit</a> in PDF format?<br />
<br />
When viewing an article, just click on the PDF icon on the right-hand side (below the article index). This allows you to download the article to your desktop, and read it later on or even print it out.<br />
<br />
You can also share downloaded articles with other people, or put it on your website, as long as you don't change the PDF.

<br /><br />----------------------------------------------------<br /><br />

<b>The Latest PHP Discussions From Around The 'Net</b><br /><br />

It's time again to look at the best PHP forum topics and posts in the past two weeks. Let's see what the PHP community has been talking about.<br />
<br />
In <a href="http://www.sitepoint.com/forums/showthread.php?t=397829">"When does one use Static Methods/Variables/Classes?"</a> the thread starter wants to know when it's okay to use static class methods and when it's not. Not surprisingly, there isn't really a good answer to this, and the thread turns into a discussion with many different opinions.<br />
<br />
Related to this thread is <a href="http://framework.zend.com/wiki/spaces/viewthread.action?key=ZFMLGEN&id=954">"Why all the static use of classes?"</a>. This thread, part of the Zend Framework mailing list, is about the excessive use of static methods in the Zend Framework, and the author would like to know why. Just like the previous thread, a discussion starts on the proper use of static classes, and no real conclusion is reached. A very interesting discussion nonetheless.<br />
<br />
In <a href="http://www.sitepoint.com/forums/showthread.php?t=393242">"ApplicationController revised"</a> the author, Ezku, posts his idea for an ApplicationController, and asks for feedback from other members. Not a lot of response so far, but a few posts down in the thread forum member kyberfabrikken posts about his own framework, and shows how his ApplicationController works, and it's a very fascinating post, and definitely worth reading.<br />
<br />
Whilst we're on the subject of controllers, in <a href="http://www.sitepoint.com/forums/showthread.php?t=395308">"Front Controller Delegating to Page Controller"</a> the author wants to know if his current Front Controller implementation is solid enough, or if it needs to be improved in some areas. General feedback in the thread seems to be that it's fairly good, although a few suggestions are offered.<br />
<br />
In <a href="http://www.sitepoint.com/forums/showthread.php?t=395461">"Superglobal wrapper object help"</a> the SitePoint members discuss the use of a superglobal or request wrapper, and the cons of pros of using such a wrapper. Some argue against it, since isn't really necessary, but others disagree, and argue that superglobals are still globals and should therefore be avoided. <br />
<br />
If you're looking for some helper scripts for the SimpleTest library, have a look at <a href="http://www.sitepoint.com/forums/showthread.php?t=395209">"Little SimpleTest helper"</a>, where several members, including me, post their helper scripts for SimpleTest, like a unit test manager, a factory class for mock objects, a run_test function and more. Not a lot of information or discussion in this thread, but plenty of useful code snippets!<br />
<br />
In <a href="http://www.sitepoint.com/forums/showthread.php?t=395035">"Help choosing a format for external language files"</a> the thread starter is looking for suggestions on the type of file he should use as his language files. Many suggestions are given, such as INI, XML, YAML and more. Personally, I'd use XML myself since it's the easiest to use and still very flexible, but INI files are a good choice as well.<br />
<br />
And finally, in <a href="http://www.phpit.net/forums/showthread.php?p=2345">"MVC implementations"</a> the thread starter kicks off a live application design session, and will be creating an MVC implementation from scratch together with other forum members. Not a lot of input yet, but hopefully there will be soon. And what are you waiting for? Come and join the fun!

<br /><br />----------------------------------------------------<br /><br />

<b>Closing Words</b><br /><br />

That's it again for this issue, and I hope you enjoyed it. If you have any comments or feedback, please e-mail me at dennis@phpit.net.<br />
<br />
The next issue of the Digest will arrive in your inbox on or around July 18th.<br />
<br />
Until then, visit <a href="http://www.phpit.net">PHPit</a> for more PHP articles, and join us at <a href="http://www.phpit.net/forums/">PHPit Forums</a> for more PHP discussion.<br />


<br /><br />----------------------------------------------------<br /><br />


If you want to receive the PHPit Digest through e-mail (either in HTML or Plain Text format), you can do so, by subscribing <a href="http://www.aspit.net/dada/mail.cgi?f=list&l=phpit">here</a>.]]></content:encoded>	
	</item>
	<item>
		<title>PHPit Digest #19 - No mini-website, settings class, test driven development...</title>
		<link>http://digest.phpit.net/archives/19/html/</link>
		<pubDate>Tue, 20 Jun 2006 02:00:00 GMT</pubDate>
		<guid>issue19</guid>
		<description>The PHPit Digest
Weekly PHP news, articles, tips and tricks!

Newsletter Archives - http://digest.phpit.net/
Advertising - http://www.phpit.net/advertising/
Contact - http://www.phpit.net/contact/

----------------------------------------------------

In This Issue...

* Introduction: no mini-website
* The Latest PHP Articles From Around The &#039;Net
* Excerpt: Creating a PHP Settings Class
* The Latest PHP Blog Posts From Around The &#039;Net
* The Latest PHP Discussions From Around The &#039;Net
* Closing Words

----------------------------------------------------

Introduction: no mini-website

Welcome to this new issue of the Digest, again filled with the latest PHP information, news and more!

In the past few issues I mentioned the possibility of a mini-website for the Digest, but I&#039;ve decided against it, even though I already had a design ready. I don&#039;t think it will add more value to the Digest, and I&#039;d rather spend more time on the Digest, than on a separate website. So there will be no mini-website.

No Editor&#039;s Perspective in this Digest, but the other usual sections are there: the latest blog posts, threads and articles, and an excerpt of the latest articles on PHPit.

 Happy Reading!

Dennis Pallett
dennis@phpit.net 

----------------------------------------------------

The Latest PHP Articles From Around The &#039;Net

There have been many new PHP articles again in the last two weeks, so let&#039;s go through the best ones.

Of course DevShed has published a few new articles, and they&#039;re all top-notch quality. In &quot;The Basics of Serializing Objects in PHP&quot; (http://www.devshed.com/c/a/PHP/The-Basics-of-Serializing-Objects-in-PHP/), which is the first part of a new article series, you are introduced to object serialization and a number of the tasks for which you can put this approach to use. Since it&#039;s only the first part, you are mostly introduced to some core concepts of object serialization and given some simple examples. The second part, &quot;Using the Sleep and Wakeup Functions to Serialize Objects in PHP&quot; (http://www.devshed.com/c/a/PHP/Using-the-Sleep-and-Wakeup-Functions-to-Serialize-Objects-in-PHP/), has also been published already, and in this part you will be introduced to the __sleep() and __wakeup() magic functions which are available when serializing and unserializing an object.

DevShed has also started a new article series on the SimpleXML library, which comes standard with PHP5. In the first part, &quot;Introducing SimpleXML in PHP 5&quot; (http://www.devshed.com/c/a/PHP/Introducing-SimpleXML-in-PHP-5/) you are introduced to the library, and the author shows you a few things that are possible with the library, like using the simplexml_load_file() function to read in XML files. Then in the second part, &quot;Loading XML Strings with simpleXML in PHP 5&quot; (http://www.devshed.com/c/a/PHP/Loading-XML-Strings-with-simpleXML-in-PHP-5/), the author shows you how to read XML strings with the simplexml_load_string() function.

Speaking of XML, PHPBuilder has posted part 5 of their &quot;Using XML&quot; series. &quot;Using XML, Part 5: SOAP and WSDL&quot; (http://www.phpbuilder.com/columns/adam_delves20060606.php3) focuses on SOAP and WSDL, and demonstrates how PHP can act as a SOAP web client. The article gives a clear overview on what SOAP actually is, and how to use it in PHP.

PHPBuilder has also published an article on using the PEAR::Image_Graph package. In the article (http://www.phpbuilder.com/columns/ian_gilfillan20060613.php3) the author shows you how to create various charts with the PEAR package, and the article includes multiple demo&#039;s and code examples.

Weberdev has posted part two of their &quot;User Authentication With patUser&quot; (http://www.weberdev.com/ViewArticle/460) series, and in this part you will be shown some of patUser&#039;s more advanced functionality, like user groups. Another article highly worth reading is &quot;HTTP Authentication with HTML Forms&quot; (http://www.peej.co.uk/articles/http-auth-with-html-forms.html), in which the author explains how to use HTTP Authentication with HTML forms, instead of the standard dialog. This is the first tutorial I&#039;ve seen that explains how to do this, and it&#039;s well-known that you can&#039;t use a HTML form with HTTP Authentication, but this tutorial shows you how to do it anyway, with some help of Ajax.

And finally, PHPit has also published two new articles and a book review. In &quot;An introduction to Test Driven Development with PHP&quot; (http://www.phpit.net/article/introduction-tdd-php/) you are taken through the steps necessary when employing the Test Driven Development principle, and it&#039;s a highly practical and useful tutorial for anyone looking to get started with TDD. In &quot;Creating a PHP Settings Class&quot; (http://www.phpit.net/article/create-settings-class-php/) you are shown how to create a Settings class which can handle different setting formats (e.g. INI, XML, etc) using a base (abstract) class and multiple child classes, which is also known as polymorphism. If you want to know more about polymorphism or abstract classes, read the review of &quot;PHP 5 Objects, Patterns and Practice&quot; (http://www.phpit.net/article/book-review-php5-objects-patterns-design/) since it&#039;s all about polymorphism, abstract classes, design patterns and more!

 To view a complete list of all the latest PHP articles, have a look at Webdev-Articles (http://www.webdev-articles.com/category/php) 

----------------------------------------------------

Excerpt: Creating a PHP Settings Class

A config.php or a settings.xml file is a very common thing for most PHP scripts, and it&#039;s usually where all the script settings (e.g. database information) are stored. The easiest way is to simply use a simple PHP script as a config file, but this may not be the best way, and it&#039;s certainly not the most user-friendly way.

In this tutorial we&#039;ll have a look at creating a Settings class which can handle any type of config format. I&#039;ll take you through the steps necessary to handle four different formats (PHP, INI, XML and YAML), but it&#039;s very easy to add more formats.

Let&#039;s get started.

 Click here to read the rest of this article &amp;raquo; (http://www.phpit.net/article/create-settings-class-php/) 

----------------------------------------------------

The Latest PHP Blog Posts From Around The &#039;Net

Planet-PHP (http://www.planet-php.net) is filled again with great blog posts on PHP and other related topics, so let&#039;s look at some interesting ones of the past two weeks.

Starting off with an interesting post by Derick Rethans. In his entry (http://derickrethans.nl/typehints_for_scalar_types.php) he talks about typehints for scalar types, like integer and string. At the moment PHP5 only supports typehints for class types, but Derick&#039;s entry introduces a patch that would allow typehints for every type of variable. Looks very useful to me, and hopefully it&#039;ll be included in a future version of PHP.

Lukas Smith has a short entry (http://pooteeweet.org/blog/430) on two proxy classes that he wrote which can be used to switch between error handling in PEAR packages. At the moment package maintainers are still (heavily) debating whether to use PEAR_Error or PEAR_Exception, and nothing has been decided yet, but with Lukas&#039; classes it makes it easier to switch later on.

Just like last time, Sott Johnson has another debugging tip. This time (http://fuzzyblog.com/archives/2006/06/15/a-php-debugging-tip-too-useful-not-to-blog/) he talks about his get_caller_context() function, which is used to see how a certain function was called. Seems like a pretty useful function to me, and I have to admit that I could&#039;ve used a function like this when I needed to trace a function call.

Clay Loveless writes about his frustrations with &#039;Loner Applications&#039;. In his entry (http://www.killersoft.com/randomstrings/2006/06/14/stop-writing-loner-applications/) he mentions several great PHP scripts (e.g. WordPress, FUDforum, etc), but they all lack something: interoperability. You can&#039;t easily use multiple PHP scripts, because each script requires its own user/authentication system. His entry makes sense, and I fully agree, but at the same time I disagree. It&#039;s not easy to make your authentication system pluggable, and it&#039;s usually one of the last things on the to-do list.

If you&#039;re looking for some help on installing the pecl/http (http://pecl.php.net/package/pecl_http) extension, have a look at this entry by Mike Wallner (http://blog.iworks.at/?/archives/45-guid.html). He doesn&#039;t take you through all the installation steps, but he does explain the different configuration options that are available during installation.

And last but not least, Enygma from PHPDeveloper.org (http://www.phpdeveloper.org) has an entry on his personal blog (http://blog.phpdeveloper.org/?p=34) in which he explains how to include Akismet in your PHP scripts. Quite a useful entry, although a bit sparse on the details. There&#039;s on article on PHPit (http://www.phpit.net/article/no-spam-akismet-php/) as well that will describe how to integrate Akismet.

----------------------------------------------------

The Latest PHP Discussions From Around The &#039;Net

It&#039;s time again to have a look at the best forum threads in the past two weeks.

Let&#039;s kick it off with &quot;Pragmatic MVC&quot; (http://www.sitepoint.com/forums/showthread.php?t=391833&amp;page=1&amp;pp=25). It&#039;s originally about an implementation of the MVC pattern, but halfway through the thread an interesting discussion starts on whether to use $_GET directly throughout your script, or if you should use a Request Wrapper. It&#039;s pretty much one person defending the use of $_GET versus the rest defending a Request Wrapper, but both sides make very good points, and it&#039;s an interesting read.

Next up is &quot;Can &quot;exit;&quot; cause a corrupt state or data?&quot; (http://www.sitepoint.com/forums/forumdisplay.php?f=147) in which the thread starter wants to know whether an exit(); call can cause corruption of data, because the PHP script doesn&#039;t completely finish. The general consensus of the thread seems to be that there&#039;s nothing to worry about.

In &quot;Dynamic &amp; Cached Content&quot; (http://www.sitepoint.com/forums/showthread.php?t=390933) the thread starter is asking for advice on different strategies on caching data. Several suggestions are given, like using the PEAR::Cache_Lite package or using a simple expiring cache, which makes this a useful thread if you&#039;re in need for a good caching strategy as well.

Another useful thread is &quot;Database singleton and unit testing&quot; (http://www.sitepoint.com/forums/showthread.php?t=389032). The thread starter wants to know how to unit test a Singleton, and unfortunately, you can&#039;t properly unit test Singletons. But as usual, many helpful replies are given, and the thread starter is pointed towards the Registry pattern, which still allows for global use, and makes unit testing possible. See the thread for full information and sample code.

If you&#039;re wondering whether to get a PHP debugger, have a look at &quot;Are debuggers like DBG really necessary?&quot; (http://www.sitepoint.com/forums/showthread.php?t=389717). In this thread the thread starter wants to know whether he should get a debugger for PHP, and if there are any advantages. Some people don&#039;t think it&#039;s necessary, especially if you&#039;ve got proper unit tests and well-designed scripts, but others do believe it&#039;s necessary, especially when you&#039;re maintaining old and bad-designed code. Jim Plush makes some interesting replies in this thread, and it&#039;s highly worth reading.

In &quot;MVC Dashboard&quot; (http://www.sitepoint.com/forums/showthread.php?t=388611) the thread starter wants to know how to create a dashboard, which usually lists a summary of all the data in a script, in his MVC script. This can be a bit troublesome, since you need data from several different models, but many great suggestions are given in the thread to overcome this problem.

Over at our own PHPit forums, forum member dhaval has posted a really useful web class called gURL (http://www.phpit.net/forums/showthread.php?t=1418). The class is fairly small, but has the same basic functionality as the cURL library. Unfortunately it doesn&#039;t have any of the advanced functionality (like custom user agent, following redirects, etc), but this may come in the future.

And finally in &quot;PHP Design Strategies&quot; (http://forums.devshed.com/php-development-5/php-design-strategies-360344.html) the thread starter wants to know how others build up their