About the Author
Acknowledgments
Tell Us What You Think!
Introduction
Who Should Read This Book?
How This Book Is Organized
Part I: Getting Started
Hour 1. PHP: From Home Page to Web Enterprise
What Is PHP?
What Need Does PHP Fulfill?
What's New in PHP 5
The Zend Engine
Why Choose PHP?
What's New in This Edition
Summary
Q&A
Workshop
Exercise
Hour 2. Installing PHP
Platforms, Servers, Databases, and PHP
Where to Find PHP and More
Installing PHP for Linux and Apache
Some configure Options
Configuring Apache
php.ini
Help!
Summary
Q&A
Workshop
Exercise
Hour 3. A First Script
Our First Script
Combining HTML and PHP
Adding Comments to PHP Code
Summary
Q&A
Workshop
Exercise
Part II: The Language
Hour 4. The Building Blocks
Variables
Data Types
Operators and Expressions
Constants
Summary
Q&A
Workshop
Exercises
Hour 5. Going with the Flow
Switching Flow
Loops
Code Blocks and Browser Output
Summary
Q&A
Workshop
Exercises
Hour 6. Functions
What Is a Function?
Calling Functions
Defining a Function
Returning Values from User-Defined Functions
Dynamic Function Calls
Variable Scope
Saving State Between Function Calls with the static Statement
More About Arguments
Creating Anonymous Functions
Testing for Function Existence
Summary
Q&A
Workshop
Exercise
Hour 7. Arrays
What Is an Array?
Creating Arrays
Associative Arrays
Multidimensional Arrays
Accessing Arrays
Manipulating Arrays
Sorting Arrays
Functions Revisited
Summary
Q&A
Workshop
Exercises
Hour 8. Working with Strings
Formatting Strings
Investigating Strings
Manipulating Strings
Summary
Q&A
Workshop
Exercises
Hour 9. Objects
What Is an Object?
Creating an Object
Object Properties
Object Methods
Limiting Access to Object Properties
Limiting Access to Object Methods
Constraining Arguments to Methods with Hints
Inheritance
Testing Classes and Objects
Automatically Loading Include Files with ___autoload()
Storing and Retrieving Objects
Summary
Q&A
Workshop
Exercises
Part III : Working with PHP
Hour 10. Working with Forms
Superglobal Variables
The $_SERVER Array
A Script to Acquire User Input
Importing User Input into Global Scope
Accessing Form Input with User-Defined Arrays
Combining HTML and PHP Code on a Single Page
Using Hidden Fields to Save State
Redirecting the User
File Upload Forms and Scripts
Summary
Q&A
Workshop
Exercises
Hour 11. Working with Files
Including Files with include()
Using include_once() and include_path to Manage Larger Projects
Testing Files
Creating and Deleting Files
Opening a File for Writing, Reading, or Appending
Reading from Files
Reading the Contents of a File with file_get_contents()
Writing or Appending to a File
Writing Data to a File with file_put_contents()
Working with Directories
Summary
Q&A
Workshop
Exercises
Hour 12. Working with the DBA Functions
Beneath the Abstraction
Opening a Database
Adding Data to the Database
Amending Elements in a Database
Reading from a Database
Determining Whether an Item Exists in a Database
Deleting an Item from a Database
Adding Complex Data Structures to a Database
An Example
Summary
Q&A
Workshop
Exercises
Hour 13. Database Integration—SQL
A (Very) Brief Introduction to SQL
Connecting to the MySQL Database Server
Selecting a Database
Finding Out About Errors
Adding Data to a Table
Acquiring the Value of an Automatically Incremented Field
Accessing Information
Changing Data
SQLite: A Lightweight SQL Engine
Selecting Data
Using the PEAR DB Package
Summary
Q&A
Workshop
Exercises
Hour 14. Beyond the Box
Server Variables Revisited
A Brief Summary of an HTTP Client/Server Negotiation
Getting a Document from a Remote Address
Converting IP Addresses and Hostnames
Making a Network Connection
Sending Mail with the mail() Function
An Introduction to Streams
Summary
Q&A
Workshop
Exercises
Hour 15. Images On-the-Fly
Checking Your Configuration with gd_info()
Creating and Outputting Images
Acquiring Color
Drawing Lines
Applying Color Fills
Drawing an Arc
Drawing a Rectangle
Drawing a Polygon
Making a Color Transparent
Working with Text
Bringing It Together
Summary
Q&A
Workshop
Exercises
Hour 16. Working with Dates and Times
Getting the Date with time()
Converting a Timestamp with getdate()
Converting a Timestamp with date()
Creating Timestamps with mktime()
An Example
A Date Pull-down Library
Summary
Q&A
Workshop
Exercise
Hour 17. Advanced Objects
Objects and Constants
Static Properties
Static Methods
Intercepting Calls to Object Properties and Methods
Final Methods
Cleaning Up Using Destructors
Managing Error Conditions with Exceptions
Tools for Building Object Hierarchies
Passing and Assigning Objects
Summary
Q&A
Workshop
Exercises
Hour 18. Working with Regular Expressions
Perl Compatible Regular Expressions
Summary
Q&A
Workshop
Exercise
Hour 19. Saving State with Cookies and Query Strings
Cookies
Setting a Cookie with PHP
Working with the Query String
Creating a Query String
Summary
Q&A
Workshop
Exercises
Hour 20. Saving State with Session Functions
What Are Session Functions?
Starting a Session with session_start()
Working with Session Variables
Destroying Sessions and Unsetting Elements
Passing Session IDs in the Query String
Encoding and Decoding Session Variables
Summary
Q&A
Workshop
Exercises
Hour 21. Working with the Server Environment
Opening Pipes to and from Processes with popen() and proc_open()
Running Commands with exec()
Running External Commands with system() or the Backtick Operator
Plugging Security Holes with escapeshellcmd()
Running External Applications with passthru()
Calling an External CGI Script with the virtual() Function
Summary
Q&A
Workshop
Exercises
Hour 22. XML
What Is XML?
XML Parser Functions
An Introduction to the DOM XML Functions
XSL: A Brief Discussion
Introducing SimpleXML
Summary
Q&A
Workshop
Exercises
Part IV: Extending PHP
Hour 23. PEAR: Reusable Components to Extend the Power of PHP
What Is PEAR?
Some PEAR Packages in Action
PEAR and Your Own Code
Summary
Q&A
Workshop
Exercises
Hour 24. Toward a Framework for Larger Projects
Principles and Problems
The Controller Object
The RequestHelper and DataStore Classes
The CommandFactory Class
The Command Class
The Dispatcher Class
Working with the Framework
Where Now, and Was It Worth It?
Summary
Q&A
Workshop
Exercises
Glossary
Index
Bookmarks