|
|
|
Copyright
|
|
|
|
Special thanks
|
|
|
|
Introduction
|
|
|
|
|
What is PHP?
|
|
|
|
|
Why Use PHP
|
|
|
|
|
How PHP Works
|
|
|
|
|
What You'll Need
|
|
|
|
|
About This Book
|
|
|
|
|
Companion Web Site
|
|
|
|
|
|
Chapter 1. Getting Started with PHP
|
|
|
|
|
Basic Syntax
|
|
|
|
|
Sending Data to the Browser
|
|
|
|
|
Testing Your Script
|
|
|
|
|
Sending Text to the Browser
|
|
|
|
|
Sending HTML to the Browser
|
|
|
|
|
Using White Space in PHP (and HTML)
|
|
|
|
|
Adding Comments to Your Scripts
|
|
|
|
|
|
Chapter 2. Variables
|
|
|
|
|
What are Variables?
|
|
|
|
|
Variable Syntax
|
|
|
|
|
Types of Variables
|
|
|
|
|
Numbers
|
|
|
|
|
Strings
|
|
|
|
|
Arrays
|
|
|
|
|
Assigning Values to Variables
|
|
|
|
|
Predefined Variables
|
|
|
|
|
|
Chapter 3. HTML Forms and PHP
|
|
|
|
|
Creating a Simple Form
|
|
|
|
|
Using Get or Post
|
|
|
|
|
Receiving Data from a Form in PHP
|
|
|
|
|
Inputting Data Manually
|
|
|
|
|
|
Chapter 4. Using Numbers
|
|
|
|
|
Adding, Subtracting, Multiplying, and Dividing
|
|
|
|
|
Formatting Numbers
|
|
|
|
|
Incrementing and Decrementing a Number
|
|
|
|
|
Using Multiple Operators
|
|
|
|
|
Using Built-in Mathematical Functions
|
|
|
|
|
|
Chapter 5. Using Strings
|
|
|
|
|
Trimming Strings
|
|
|
|
|
Connecting Strings (Concatenation)
|
|
|
|
|
Encoding and Decoding Strings
|
|
|
|
|
Encrypting and Decrypting Strings
|
|
|
|
|
Pulling Out Parts from a String
|
|
|
|
|
|
Chapter 6. Control Structures
|
|
|
|
|
The If Conditional
|
|
|
|
|
More Operators
|
|
|
|
|
Comparison
|
|
|
|
|
Logical
|
|
|
|
|
Using Else
|
|
|
|
|
Using Elseif
|
|
|
|
|
The Switch Conditional
|
|
|
|
|
The While Loop
|
|
|
|
|
The For Loop
|
|
|
|
|
|
Chapter 7. Using Arrays
|
|
|
|
|
Creating an Array
|
|
|
|
|
Adding Items to an Array
|
|
|
|
|
Accessing Array Elements
|
|
|
|
|
Sorting Arrays
|
|
|
|
|
Transforming Between Strings and Arrays
|
|
|
|
|
Creating an Array from a Form
|
|
|
|
|
Creating Multidimensional Arrays
|
|
|
|
|
|
Chapter 8. Regular Expressions
|
|
|
|
|
What are Regular Expressions?
|
|
|
|
|
Defining a Simple Pattern
|
|
|
|
|
Matching Patterns
|
|
|
|
|
Defining More Complicated Patterns
|
|
|
|
|
Matching and Replacing Patterns
|
|
|
|
|
|
Chapter 9. Creating Functions
|
|
|
|
|
Creating and Using Simple Functions
|
|
|
|
|
Creating and Calling Functions that Take Arguments
|
|
|
|
|
Creating and Using Functions that Return a Value
|
|
|
|
|
Variables and Functions
|
|
|
|
|
Setting default argument values
|
|
|
|
|
|
Chapter 10. Files and Directories
|
|
|
|
|
File Permissions
|
|
|
|
|
Writing to Files
|
|
|
|
|
Reading from Files
|
|
|
|
|
Directories
|
|
|
|
|
Handling File Uploads
|
|
|
|
|
Renaming and Deleting Files and Directories
|
|
|
|
|
|
Chapter 11. Databases
|
|
|
|
|
Connecting to and Creating a Database
|
|
|
|
|
Creating a Table
|
|
|
|
|
Sending Data to a Database
|
|
|
|
|
Retrieving Data from a Database
|
|
|
|
|
|
Chapter 12. Cookies
|
|
|
|
|
Creating and Reading from Cookies
|
|
|
|
|
Adding Parameters to a Cookie
|
|
|
|
|
Deleting a Cookie
|
|
|
|
|
|
Chapter 13. Creating Web Applications
|
|
|
|
|
Using include and require
|
|
|
|
|
Determining the Date and Time
|
|
|
|
|
Using HTTP Headers
|
|
|
|
|
Sending Email
|
|
|
|
|
|
Chapter 14. Debugging
|
|
|
|
|
Common Errors
|
|
|
|
|
Error Reporting and Logging
|
|
|
|
|
Debugging Detective Work
|
|
|
|
|
Using the Die Statement
|
|
|
|
|
|
Appendix A. Installation and Configuration
|
|
|
|
|
Installing on a Linux Server
|
|
|
|
|
Installing on a Windows 2000 Server
|
|
|
|
|
Configuration
|
|
|
|
|
|
Appendix B. Security
|
|
|
|
|
Cryptography and SSL
|
|
|
|
|
Writing Secure PHP
|
|
|
|
|
Security Resources
|
|
|
|
|
|
Appendix C. PHP Resources
|
|
|
|
|
The PHP Manual
|
|
|
|
|
Web sites and Newsgroups
|
|
|
|
|
Database Resources
|
|
|
|
|
Advanced Topics
|
|
|
|
|
Tables
|
|
|