Please consider the latest edition.
-
Chapter 1 Strings
-
Introduction
-
Accessing Substrings
-
Replacing Substrings
-
Processing a String One Character at a Time
-
Reversing a String by Word or Character
-
Expanding and Compressing Tabs
-
Controlling Case
-
Interpolating Functions and Expressions Within Strings
-
Trimming Blanks from a String
-
Parsing Comma-Separated Data
-
Parsing Fixed-Width Delimited Data
-
Taking Strings Apart
-
Wrapping Text at a Certain Line Length
-
Storing Binary Data in Strings
-
-
Chapter 2 Numbers
-
Introduction
-
Checking Whether a String Contains a Valid Number
-
Comparing Floating-Point Numbers
-
Rounding Floating-Point Numbers
-
Operating on a Series of Integers
-
Generating Random Numbers Within a Range
-
Generating Biased Random Numbers
-
Taking Logarithms
-
Calculating Exponents
-
Formatting Numbers
-
Printing Correct Plurals
-
Calculating Trigonometric Functions
-
Doing Trigonometry in Degrees, not Radians
-
Handling Very Large or Very Small Numbers
-
Converting Between Bases
-
Calculating Using Numbers in Bases Other Than Decimal
-
-
Chapter 3 Dates and Times
-
Introduction
-
Finding the Current Date and Time
-
Converting Time and Date Parts to an Epoch Timestamp
-
Converting an Epoch Timestamp to Time and Date Parts
-
Printing a Date or Time in a Specified Format
-
Finding the Difference of Two Dates
-
Finding the Difference of Two Dates with Julian Days
-
Finding the Day in a Week, Month, Year, or the Week Number in a Year
-
Validating a Date
-
Parsing Dates and Times from Strings
-
Adding to or Subtracting from a Date
-
Calculating Time with Time Zones
-
Accounting for Daylight Saving Time
-
Generating a High-Precision Time
-
Generating Time Ranges
-
Using Non-Gregorian Calendars
-
Program: Calendar
-
-
Chapter 4 Arrays
-
Introduction
-
Specifying an Array Not Beginning at Element 0
-
Storing Multiple Elements per Key in an Array
-
Initializing an Array to a Range of Integers
-
Iterating Through an Array
-
Deleting Elements from an Array
-
Changing Array Size
-
Appending One Array to Another
-
Turning an Array into a String
-
Printing an Array with Commas
-
Checking if a Key Is in an Array
-
Checking if an Element Is in an Array
-
Finding the Position of an Element in an Array
-
Finding Elements That Pass a Certain Test
-
Finding the Largest or Smallest Valued Element in an Array
-
Reversing an Array
-
Sorting an Array
-
Sorting an Array by a Computable Field
-
Sorting Multiple Arrays
-
Sorting an Array Using a Method Instead of a Function
-
Randomizing an Array
-
Shuffling a Deck of Cards
-
Removing Duplicate Elements from an Array
-
Finding the Union, Intersection, or Difference of Two Arrays
-
Finding All Element Combinations of an Array
-
Finding All Permutations of an Array
-
Program: Printing an Array in a Horizontally Columned HTML Table
-
-
Chapter 5 Variables
-
Introduction
-
Avoiding == Versus = Confusion
-
Establishing a Default Value
-
Exchanging Values Without Using Temporary Variables
-
Creating a Dynamic Variable Name
-
Using Static Variables
-
Sharing Variables Between Processes
-
Encapsulating Complex Data Types as a String
-
Dumping Variable Contents as Strings
-
-
Chapter 6 Functions
-
Introduction
-
Accessing Function Parameters
-
Setting Default Values for Function Parameters
-
Passing Values by Reference
-
Using Named Parameters
-
Creating Functions That Take a Variable Number of Arguments
-
Returning Values by Reference
-
Returning More Than One Value
-
Skipping Selected Return Values
-
Returning Failure
-
Calling Variable Functions
-
Accessing a Global Variable Inside a Function
-
Creating Dynamic Functions
-
-
Chapter 7 Classes and Objects
-
Introduction
-
Instantiating Objects
-
Defining Object Constructors
-
Destroying an Object
-
Cloning Objects
-
Assigning Object References
-
Calling Methods on an Object Returned by Another Method
-
Accessing Overridden Methods
-
Using Property Overloading
-
Using Method Polymorphism
-
Finding the Methods and Properties of an Object
-
Adding Properties to a Base Object
-
Creating a Class Dynamically
-
Instantiating an Object Dynamically
-
-
Chapter 8 Web Basics
-
Introduction
-
Setting Cookies
-
Reading Cookie Values
-
Deleting Cookies
-
Redirecting to a Different Location
-
Using Session Tracking
-
Storing Sessions in a Database
-
Detecting Different Browsers
-
Building a GET Query String
-
Using HTTP Basic Authentication
-
Using Cookie Authentication
-
Flushing Output to the Browser
-
Buffering Output to the Browser
-
Compressing Web Output with gzip
-
Hiding Error Messages from Users
-
Tuning Error Handling
-
Using a Custom Error Handler
-
Logging Errors
-
Eliminating "headers already sent" Errors
-
Logging Debugging Information
-
Reading Environment Variables
-
Setting Environment Variables
-
Reading Configuration Variables
-
Setting Configuration Variables
-
Communicating Within Apache
-
Profiling Code
-
Program: Website Account (De)activator
-
Program: Abusive User Checker
-
-
Chapter 9 Forms
-
Introduction
-
Processing Form Input
-
Validating Form Input
-
Working with Multipage Forms
-
Redisplaying Forms with Preserved Information and Error Messages
-
Guarding Against Multiple Submission of the Same Form
-
Processing Uploaded Files
-
Securing PHP's Form Processing
-
Escaping Control Characters from User Data
-
Handling Remote Variables with Periods in Their Names
-
Using Form Elements with Multiple Options
-
Creating Dropdown Menus Based on the Current Date
-
-
Chapter 10 Database Access
-
Introduction
-
Using Text-File Databases
-
Using DBM Databases
-
Connecting to a SQL Database
-
Querying a SQL Database
-
Retrieving Rows Without a Loop
-
Modifying Data in a SQL Database
-
Repeating Queries Efficiently
-
Finding the Number of Rows Returned by a Query
-
Escaping Quotes
-
Logging Debugging Information and Errors
-
Assigning Unique ID Values Automatically
-
Building Queries Programmatically
-
Making Paginated Links for a Series of Records
-
Caching Queries and Results
-
Program: Storing a Threaded Message Board
-
-
Chapter 11 Web Automation
-
Introduction
-
Fetching a URL with the GET Method
-
Fetching a URL with the POST Method
-
Fetching a URL with Cookies
-
Fetching a URL with Headers
-
Fetching an HTTPS URL
-
Debugging the Raw HTTP Exchange
-
Marking Up a Web Page
-
Extracting Links from an HTML File
-
Converting ASCII to HTML
-
Converting HTML to ASCII
-
Removing HTML and PHP Tags
-
Using Smarty Templates
-
Parsing a Web Server Log File
-
Program: Finding Stale Links
-
Program: Finding Fresh Links
-
-
Chapter 12 XML
-
Introduction
-
Generating XML Manually
-
Generating XML with the DOM
-
Parsing XML with the DOM
-
Parsing XML with SAX
-
Transforming XML with XSLT
-
Sending XML-RPC Requests
-
Receiving XML-RPC Requests
-
Sending SOAP Requests
-
Receiving SOAP Requests
-
Exchanging Data with WDDX
-
Reading RSS Feeds
-
-
Chapter 13 Regular Expressions
-
Introduction
-
Switching From ereg to preg
-
Matching Words
-
Finding the nth Occurrence of a Match
-
Choosing Greedy or Nongreedy Matches
-
Matching a Valid Email Address
-
Finding All Lines in a File That Match a Pattern
-
Capturing Text Inside HTML Tags
-
Escaping Special Characters in a Regular Expression
-
Reading Records with a Pattern Separator
-
-
Chapter 14 Encryption and Security
-
Introduction
-
Keeping Passwords Out of Your Site Files
-
Obscuring Data with Encoding
-
Verifying Data with Hashes
-
Storing Passwords
-
Checking Password Strength
-
Dealing with Lost Passwords
-
Encrypting and Decrypting Data
-
Storing Encrypted Data in a File or Database
-
Sharing Encrypted Data with Another Web Site
-
Detecting SSL
-
Encrypting Email with GPG
-
-
Chapter 15 Graphics
-
Introduction
-
Drawing Lines, Rectangles, and Polygons
-
Drawing Arcs, Ellipses, and Circles
-
Drawing with Patterned Lines
-
Drawing Text
-
Drawing Centered Text
-
Building Dynamic Images
-
Getting and Setting a Transparent Color
-
Serving Images Securely
-
Program: Generating Bar Charts from Poll Results
-
-
Chapter 16 Internationalization and Localization
-
Introduction
-
Listing Available Locales
-
Using a Particular Locale
-
Setting the Default Locale
-
Localizing Text Messages
-
Localizing Dates and Times
-
Localizing Currency Values
-
Localizing Images
-
Localizing Included Files
-
Managing Localization Resources
-
Using gettext
-
Reading or Writing Unicode Characters
-
-
Chapter 17 Internet Services
-
Introduction
-
Sending Mail
-
Sending MIME Mail
-
Reading Mail with IMAP or POP3
-
Posting Messages to Usenet Newsgroups
-
Reading Usenet News Messages
-
Getting and Putting Files with FTP
-
Looking Up Addresses with LDAP
-
Using LDAP for User Authentication
-
Performing DNS Lookups
-
Checking if a Host Is Alive
-
Getting Information About a Domain Name
-
-
Chapter 18 Files
-
Introduction
-
Creating or Opening a Local File
-
Creating a Temporary File
-
Opening a Remote File
-
Reading from Standard Input
-
Reading a File into a String
-
Counting Lines, Paragraphs, or Records in a File
-
Processing Every Word in a File
-
Reading a Particular Line in a File
-
Processing a File Backward by Line or Paragraph
-
Picking a Random Line from a File
-
Randomizing All Lines in a File
-
Processing Variable Length Text Fields
-
Reading Configuration Files
-
Reading from or Writing to a Specific Location in a File
-
Removing the Last Line of a File
-
Modifying a File in Place Without a Temporary File
-
Flushing Output to a File
-
Writing to Standard Output
-
Writing to Many Filehandles Simultaneously
-
Escaping Shell Metacharacters
-
Passing Input to a Program
-
Reading Standard Output from a Program
-
Reading Standard Error from a Program
-
Locking a File
-
Reading and Writing Compressed Files
-
Program: Unzip
-
-
Chapter 19 Directories
-
Introduction
-
Getting and Setting File Timestamps
-
Getting File Information
-
Changing File Permissions or Ownership
-
Splitting a Filename into Its Component Parts
-
Deleting a File
-
Copying or Moving a File
-
Processing All Files in a Directory Recursively
-
Getting a List of Filenames Matching a Pattern
-
Processing All Files in a Directory
-
Making New Directories
-
Removing a Directory and Its Contents
-
Program: Web Server Directory Listing
-
Program: Site Search
-
-
Chapter 20 Client-Side PHP
-
Introduction
-
Parsing Program Arguments
-
Parsing Program Arguments with getopt
-
Reading from the Keyboard
-
Reading Passwords
-
Displaying a GUI Widget in a Window
-
Displaying Multiple GUI Widgets in a Window
-
Responding to User Actions
-
Displaying Menus
-
Program: Command Shell
-
Program: Displaying Weather Conditions
-
-
Chapter 21 PEAR
-
Introduction
-
Using the PEAR Package Manager
-
Finding PEAR Packages
-
Finding Information About a Package
-
Installing PEAR Packages
-
Installing PECL Packages
-
Upgrading PEAR Packages
-
Uninstalling PEAR Packages
-
Documenting Classes with PHPDoc
-
-
Colophon
- Title:
- PHP Cookbook
- By:
- David Sklar, Adam Trachtenberg
- Publisher:
- O'Reilly Media
- Formats:
-
- Safari Books Online
- Print Release:
- November 2002
- Pages:
- 640
- Print ISBN:
- 978-1-56592-681-3
- | ISBN 10:
- 1-56592-681-1
Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The animal on the cover of PHP Cookbook is a Galapagos land iguana (Conolophus subcristatus). Once abundant in the Galapagos Islands, this iguana proved tasty to the settlers of the early 1800s, and domestic animals later introduced on the islands played further havoc with the reptile's home and food supply. Today there are no iguanas left on Santiago Island and very few left on the other islands.
Distantly related to the green iguana of the South American continent, Galapagos land iguanas can be over three feet long, with males weighing up to 30 pounds. Their tough, scaly skin is yellow with scattered patches of white, black, brown, and rust. These lizards resemble mythical creatures of the past-- dragons with long tails, clawed feet, and spiny crests. In reality, however, they are harmless.
Land iguanas live in the drier areas of the islands and in the morning are found basking in the sun. During midday, however, they seek the shade of cactus, rocks, and trees. To conserve body heat at night, they sleep in burrows dug in the ground.
These reptiles are omnivores, but they generally depend on low-growing plants and shrubs, as well as the fallen fruits and pads of cactus trees. These plants provide most of the moisture they need; however, they will drink fresh water whenever it's available.
Depending on their size, land iguanas reach maturity between 8 and 15 years of age. They congregate and mate during specific periods, which vary from island to island. The females then migrate to suitable areas to nest. After digging a burrow, the female lays 2 to 20 eggs in the nest. She then defends the covered nest site to prevent other females from nesting in the same spot. Young iguanas hatch 85 to 110 days later and take about a week to dig their way out of the nest. Normally, if hatchlings survive the first year when food is often scarce and native predators such as hawks, egrets, herons, and snakes are a danger, they can live for more than 60 years. In reality, predation by feral cats is far worse because the young must survive and grow for at least three to four years before becoming large enough that cats can't kill them. Mary Anne Weeks Mayo was the production editor and copyeditor for PHP Cookbook. Sarah Jane Shangraw proofread the book. Darren Kelly and Jane Ellin provided quality control. Julie Flanagan, Brian Sawyer, Genevieve d'Entremont, and Judy Hoer provided production assistance. Ellen Troutman-Zaig wrote the index.
Emma Colby designed the cover of this book, based on a series design by Edie Freedman. The cover image is a 19th-century engraving from the Dover Pictorial Archive. Emma produced the cover layout with QuarkXPress 4.1 using Adobe's ITC Garamond font.
David Futato designed the interior layout. This book was converted to FrameMaker 5.5.6 with a format conversion tool created by Erik Ray, Jason McIntosh, Neil Walls, and Mike Sierra that uses Perl and XML technologies. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is Lucas-Font's TheSans Mono Condensed. The illustrations that appear in the book were produced by Robert Romano and Jessamyn Read using Macromedia FreeHand 9 and Adobe Photoshop 6. This colophon was compiled by Mary Anne Weeks Mayo.
