Flylib.com

Books Software

 
 
 

DB.php and Its Use in This Book


DB.php and Its Use in This Book

In recipes where database access is required, I use DB.php to access the database. DB.php is used only in PHP 4, and is not fully mature at the time of writing, so I decided not to spend Chapter 12 covering it. For more information about DB.php, please check out PEAR at http://pear.php.net/


The History of PHP

PHP, like many great things, arose out of necessity. Rasmus Lerdorf wrote the initial version of PHP in an afternoon, during a period between contracts when he needed a quick tool to track users who were reading his online resume. However, the initial PHP, a Perl/CGI wrapper, was experiencing growing pains on the Web server where his resume was located. So, Rasmus decided to rewrite the Perl wrapper in C to eliminate the overhead of forking Perl each time his resume was accessed.

After some time, people who were on the same Web server noticed Rasmus' wrapper and asked him if they could use it, and the rest is history. As more people used his wrapper, they asked for more features, which made more people want to use the wrapper.

Finally, Rasmus decided to put together a somewhat complete distribution along with documentation, a mailing list, and a FAQ. This first distribution was called Personal Home Page Tools, which later transformed into the Personal Home Page Construction Kit.

While Rasmus was working on PHP, he also was working on a tool to embed SQL queries easily into a Web page. In the most basic sense, it was another CGI wrapper that parsed SQL queries and made it easy to create forms and tables based on those queries. The name of this tool just happened to be FI (Form Interpreter).

PHP/FI 2.0 was a rebirth of both PHP and FI rewritten into one program. PHP/FI was an easy programming language rather than a simple CGI wrapper. It enabled programmers to embed simple scripts directly into a Web page.

PHP/FI became quite popular among developers, and it caught the eye of Andi Gutmans and Zeev Suraski, who ”although they liked the fundamental idea of PHP/FI ”disagreed on the implementation. Andi and Zeev rewrote PHP/FI and PHP 3 was born.

PHP 3 was a huge improvement over PHP/FI. It featured better performance, cleaner syntax, object-oriented support, the for loop, and many other improvements. PHP 3 has enjoyed incredible success. According to the latest Netcraft survey, PHP 3 is by far the most popular Apache server module, installed on more than 1.5 million Web servers.


Enter PHP 4

The PHP 3 engine, although extremely popular and sufficiently fast, was starting to suffer from growing pains as more and more people used it for increasingly complex applications. Therefore, the creators of the PHP 3 engine, Zeev Suraski and Andi Gutmans, decided that a complete rewrite was due.

The result of that rewrite is the Zend engine (named after Zeev and Andi). The Zend engine is the core of PHP 4, which offers greatly improved performance and a host of new features. It expands PHP's viability, making it an excellent tool for complex Web applications as well as small-to-medium size Web sites.


Improved Performance

One of the greatest features in PHP 4 is the performance boost it gives over PHP 3. Tests (available from Zend) show that the same scripts run with PHP 4 instead of PHP 3 show a 50 “1,000% performance increase. You can also use PHP 4 with the free Zend Optimizer (available from Zend Technologies, http://www.zend.com/), which gives PHP 4 an additional 40 “100% speed boost. How much of a speed improvement you get depends on the structure of your scripts.