Chapter 1 provides some general background on PHP and how it interacts with your
web browser and a web server. It also shows some PHP programs and what they do,
to give you an idea of what PHP programs look like. Especially if you’re new to pro‐
gramming or building dynamic websites, it is important to read Chapter 1.
The next five chapters give you a grounding in the fundamentals of PHP. Before
you can write great literature, you need to learn a little grammar and some vocabu‐
lary. That’s what these chapters are for. (Don’t worry—you’ll learn enough PHP
grammar and vocabulary right away to start writing some short programs, if not great
Chapter 2 shows you how to work with different kinds of data, such as pieces of text
and numbers. This is important because the web pages that your PHP programs gen‐
erate are just big pieces of text.
Chapter 3 describes the PHP commands that your programs can use to make deci‐
sions. These decisions are at the heart of the “dynamic” in dynamic website. The con‐
cepts in Chapter 3 are what you use, for example, to display only those items in a
product catalog that fall between two prices a user enters in a web form.
Chapter 4 introduces arrays, which are collections of a bunch of individual numbers
or pieces of text. Many frequent activities in PHP programs, such as processing sub‐
mitted web form parameters or examining information pulled out of a database,
involve using arrays.
As you write more complicated programs, you’ll find yourself wanting to repeat simi‐
lar tasks. Functions, discussed in Chapter 5, help you reuse pieces of your programs.
Chapter 6 shows how data and logic together are combined into objects. Objects are
reusable bundles of code that help you structure your programs. Objects also allow
you to integrate existing PHP add-ons and libraries into your code.
The next five chapters cover essential tasks in building a dynamic website: interacting
with users, saving information, and interacting with other websites.
Chapter 7 supplies details on working with web forms, which are the primary way
that users interact with your website.
Chapter 8 discusses databases. A database holds the information that your website
displays, such as a product catalog or event calendar. This chapter shows you how to
make your PHP programs talk to a database. With the techniques in Chapter 8, your
website can do user-specific things such as display sensitive information only to
authorized people or tell someone how many new message board posts have been
created since she last logged in.
In addition to a database, you might also need to work with data stored in files. Chap‐
ter 9 explains to how read and write files from a PHP program.
Next, Chapter 10 details how to keep track of your users. This includes using cookies
for transient data, but also users logging in to accounts and tracking session data such
as a shopping cart of products.