HomeMySQL Page 5 - Database Applications and the Web
Web Scripting with PHP - MySQL
With most of the services on the web being powered by web database applications, it becomes important for any web developer to know how bring together the web and databases to build applications. This article gets you started. It is excerpted from chapter one of the book Web Database Applications with PHP and MySQL, written by Hugh E. Williams & David Lane (O'Reilly, 2004; ISBN: 0596005431).
PHP is the most widely supported and used web scripting language and an excellent tool for building web database applications. This isnít to say that other scripting languages donít have excellent features. However, there are many reasons that make PHP a good choice, including that itís:
Community efforts to maintain and improve it are unconstrained by commercial imperatives.
Flexible for integration with HTML
One or more PHP scripts can be embedded into static HTML files and this makes client tier integration easy. On the downside, this can blend the scripts with the presentation; however the template techniques described in Chapter 7 can solve most of these problems.
Suited to complex projects
It is a fully featured object-oriented programming language, with more than 110 libraries of programming functions for tasks as diverse as math, sorting, creating PDF documents, and sending email. There are over 15 libraries for native, fast access to the database tier.
Fast at running scripts
Using its built-in Zend scripting engine, PHP script execution is fast and all components run within the main memory space of PHP (in contrast to other scripting frameworks, in which components are in distinct modules). Our experiments suggest that for tasks of at least moderate complexity, PHP is faster than other popular scripting tools.
Platform- and operating-system portable
Apache and PHP run on many different platforms and operating systems. PHP can also be integrated with other web servers.
A community effort
PHP contains PEAR, a repository that is home to over 100 freely available source code packages for common PHP programming tasks.
At the time of writing, PHP4 (Version 4.3.3) was the current version and PHP5 was available for beta testing (Version 5.0.0b2). The scripts in this book have been developed and tested using PHP4, and testing on PHP5 has identified a few limitations. This book describes both versions of PHP: in particular, youíll find a discussion of new object-oriented PHP5 features in Chapter 14. When a feature is only available in PHP5, we tell you in the text. When a PHP4 script or feature doesnít work on PHP5, we explain why and predict how itíll be fixed in the future; itís likely that almost all scripts that run under PHP4 will run under PHP5 in the future.
PHP is a major topic of this book. Itís introduced in Chapters 3 through 5, where we discuss most of the features of the core language. PHP libraries that are important to web database application development are the subject of Chapters 6 and 8 through 13. PHPís PEAR package repository is the subject of Chapter 7. An example PHP application is the subject of Chapters 16 to 20. Appendixes A through C show how to install PHP. Other pointers to web resources, books, and commercial products for PHP development are listed in Appendix G.
A technical explanation of the new features of PHP5 is presented in the next section. If you arenít familiar with PHP4, skip ahead to the next section.