Databases Reference
In-Depth Information
CHAPTER 14
PHP
In Chapter 13, we discussed how the triad of MySQL, PHP, and the Apache web server
is one of the most popular web development platforms. In this chapter, we introduce
you to building web database applications for this platform. We cover the following
topics:
• An introduction to the PHP language
• How the commonly used MySQL library functions are used to access the MySQL
DBMS
• How to handle MySQL DBMS errors, use include files to modularize code, and
secure user data
• How to write data to databases and manage sessions in applications
PHP has a large set of libraries available that can be used for tasks as diverse as string
manipulation, network communications, data compression, and disk access. We can
only touch on some of these in this topic; you'll find the PHP manual and the resources
listed at the end of this chapter invaluable as you learn more about the language.
Language Basics
This section is a short introduction to the basic syntax of PHP. If you're familiar with
high-level languages such as C, C++, Java, JavaScript, or Perl, then you'll find PHP very
easy to learn. PHP began its life as a simple, procedural language that was designed to
be embedded into HTML pages, and that's mostly what we focus on this chapter. More
recently, it has become a full-fledged object oriented (OO) language that can be used
for nonweb and cross-platform applications, including both scripts that run from the
command-line and programs with graphical user interfaces (see the PHP-GTK web site,
http://gtk.php.net ). You'll find pointers to comprehensive PHP resources in “Resour-
ces” at the end of this chapter.
As discussed previously, PHP scripts are surrounded by the PHP start tag <?php and the
PHP end tag ?> . You'll sometimes see the start tag abbreviated to <?, but this conflicts
 
Search WWH ::




Custom Search