Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

682 LESSON 24: Taking Advantage of the Server


Database Connectivity
I mentioned CRUD applications already. A CRUD application is generally just a front
end for a relational database, which in turn is an application optimized for storing data
within tables. Databases can be used to store content for websites, billing information for
an online store, payroll for a company, or anything else that can be expressed as a table.
It seems like there’s a relational database providing the storage for just about every popu-
lar website.
Because databases play such a huge role in developing web applications, PHP provides a
lot of database-related functionality. Most relational databases are applications that can be
accessed over a network, a lot like a web server. PHP is capable of connecting to every
popular relational database. To communicate with relational databases, you have to use a
language called SQL (the Structured Query Language). That’s another book unto itself.

Regular Expressions
Regular expressions comprise a small language designed to provide programmers with
a flexible way to match patterns in strings. For example, the regular expression ^a.*z$
matches a string that starts with a, ends with z, and has some number of characters in
between. You can use regular expressions to do much more fine-grained form validation
than I did in Exercise 24.1. They’re also used to extract information from files, search
and replace within strings, parse email addresses, or anything else that requires you to
solve a problem with pattern matching. Regular expressions are incredibly flexible, but
the syntax can be a bit complex.
PHP actually supports two different varieties of regular expression syntax: Perl style and
POSIX style. You can read about both of them in the PHP manual.

Sending Mail
PHP provides functions for sending email. For example, you could write a PHP script
that automatically notifies an administrator by email when a user registers for a website
or sends users a password reminder if they request one when they forget their password.
PHP also provides functions that enable your applications to retrieve mail as well as send
it, making it possible to write web-based email clients and other such applications.

Object-Oriented PHP
PHP provides features for object-oriented development if you prefer that style of pro-
gramming. For more information on object-oriented PHP, refer to the manual.
Free download pdf