-
Chapter 1 Introduction to PHP
-
PHP History
-
Advantages of PHP
-
Getting Help
-
Getting Certified
-
PHP Resources
-
-
Chapter 2 Installing PHP
-
Installing on Windows
-
Installing on Unix
-
Testing Your Configuration
-
System Configuration
-
-
Chapter 3 The PHP Interpreter
-
Running PHP Scripts
-
Extending PHP
-
PEAR
-
Abnormal Script Termination
-
-
Chapter 4 The PHP Language
-
The Basics of PHP
-
Variables
-
Whitespace
-
Heredoc
-
Brief Introduction to Variable Types
-
Code Blocks
-
Opening and Closing Code Islands
-
Comments
-
Conditional Statements
-
Case Switching
-
Loops
-
Infinite Loops
-
Special Loop Keywords
-
Loops Within Loops
-
Mixed-Mode Processing
-
Including Other Files
-
Functions
-
-
Chapter 5 Variables and Constants
-
Types of Data
-
True or False
-
Strings
-
Integers
-
Floats
-
Automatic Type Conversion
-
Checking Whether a Variable Is Set: isset()
-
Variable Scope
-
Variable Variables
-
Superglobals
-
Using $_ENV and $_SERVER
-
References
-
Constants
-
Arrays
-
-
Chapter 6 Operators
-
Arithmetic Operators
-
Assignment Operators
-
String Operators
-
Bitwise Operators
-
Comparison Operators
-
Incrementing and Decrementing Operators
-
Logical Operators
-
Some Operator Examples
-
The Ternary Operator
-
The Execution Operator
-
Operator Precedence and Associativity
-
-
Chapter 7 Function Reference
-
Undocumented Functions
-
Handling Non-English Characters
-
-
Chapter 8 Object-Oriented PHP
-
Conceptual Overview
-
Classes
-
Objects
-
Properties
-
The 'this' Variable
-
Objects Within Objects
-
Access Control Modifiers
-
Object Type Information
-
Class Type Hints
-
Constructors and Destructors
-
Copying Objects
-
Comparing Objects with == and ===
-
Saving Objects
-
Magic Methods
-
Static Class Methods and Properties
-
Helpful Utility Functions
-
Interfaces
-
Dereferencing Object Return Values
-
-
Chapter 9 HTML Forms
-
What Does It Mean to Be Dynamic?
-
Designing a Form
-
Handling Data
-
Splitting Forms Across Pages
-
Validating Input
-
Form Design
-
Summary
-
-
Chapter 10 Cookies and Sessions
-
Cookies Versus Sessions
-
Using Cookies
-
Using Sessions
-
Storing Complex Data Types
-
-
Chapter 11 Output Buffering
-
Why Use Output Buffering?
-
Getting Started
-
Reusing Buffers
-
Stacking Buffers
-
Flushing Stacked Buffers
-
Reading Buffers
-
Other OB Functions
-
Flushing Output
-
Compressing Output
-
URL Rewriting
-
-
Chapter 12 Security
-
Security Tips
-
Encryption
-
-
Chapter 13 Files
-
Reading Files
-
Creating and Changing Files
-
Moving, Copying, and Deleting Files
-
Other File Functions
-
Checking Whether a File Exists
-
Retrieving File Time Information
-
Dissecting Filename Information
-
Handling File Uploads
-
Locking Files with flock()
-
Reading File Permissions and Status
-
Changing File Permissions and Ownership
-
Working with Links
-
Working with Directories
-
Remote Files
-
File Checksums
-
Parsing a Configuration File
-
-
Chapter 14 Databases
-
Using MySQL with PHP
-
PEAR::DB
-
SQLite
-
Persistent Connections
-
MySQL Improved
-
-
Chapter 15 Regular Expressions
-
Basic Regexps with preg_match() and preg_match_all()
-
Regexp Character Classes
-
Regexp Special Characters
-
Words and Whitespace Regexps
-
Storing Matched Strings
-
Regular Expression Replacements
-
Regular Expression Syntax Examples
-
The Regular Expressions Coach
-
-
Chapter 16 Manipulating Images
-
Getting Started
-
Choosing a Format
-
Getting Arty
-
More Shapes
-
Complex Shapes
-
Outputting Text
-
Loading Existing Images
-
Color and Image Fills
-
Adding Transparency
-
Using Brushes
-
Basic Image Copying
-
Scaling and Rotating
-
Points and Lines
-
Special Effects Using imagefilter()
-
Interlacing an Image
-
Getting an Image's MIME Type
-
-
Chapter 17 Creating PDFs
-
Getting Started
-
Adding More Pages and More Style
-
Adding Images
-
PDF Special Effects
-
Adding Document Data
-
-
Chapter 18 Creating Flash
-
A Simple Movie
-
Flash Text
-
Actions
-
Animation
-
-
Chapter 19 XML & XSLT
-
SimpleXML
-
Transforming XML Using XSLT
-
-
Chapter 20 Network Programming
-
Sockets
-
HTTP
-
Sending Mail
-
Curl
-
-
Chapter 21 Distributing Your Code
-
Cross-Platform Code 1: Loading Extensions
-
Cross-Platform Code 2: Using Extensions
-
Cross-Platform Code 3: Path and Line Separators
-
Cross-Platform Code 4: Coping with php.ini Differences
-
Cross-Platform Code 5: Checking the PHP Version with phpversion() and version_compare()
-
-
Chapter 22 Debugging
-
The Most Basic Debugging Technique
-
Making Assertions
-
Triggering Your Own Errors
-
Testing with php_check_syntax()
-
Source Highlighting
-
Handling MySQL Errors
-
Exception Handling
-
Backtracing Your Code
-
Custom Error Handlers
-
Custom Exception Handlers
-
Using @ to Disable Errors
-
phpinfo()
-
Output Style
-
-
Chapter 23 Performance
-
Write Your Code Sensibly
-
Use the Zend Optimizer
-
Use a PHP Code Cache
-
Compress Your Output
-
Don't Use CGI
-
Debug Your Code
-
Use Persistent Connections
-
Compile Right
-
-
Colophon
- Title:
- PHP in a Nutshell
- By:
- Paul Hudson
- Publisher:
- O'Reilly Media
- Formats:
-
- Ebook
- Safari Books Online
- Print Release:
- October 2005
- Ebook Release:
- June 2009
- Pages:
- 384
- Print ISBN:
- 978-0-596-10067-4
- | ISBN 10:
- 0-596-10067-1
- Ebook ISBN:
- 978-0-596-10559-4
- | ISBN 10:
- 0-596-10559-2
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 in a Nutshell is a cuckoo (Cuculus canorus). Cuckoos epitomize minimal effort. The common cuckoo doesn't build a nest-instead, the female cuckoo finds another bird's nest that already contains eggs and lays an egg in it (a process she may repeat up to 25 times, leaving 1 egg per nest). The nest mother, who is usually of a different bird species, rarely notices the addition, and usually incubates the egg and then feeds the hatchling as if it were her own. Why don't nest mothers notice that the cuckoo's eggs are different from their own eggs? Recent research suggests that it's because the eggs look the same in the ultraviolet spectrum, which birds can see.
When they hatch, the baby cuckoos push all the other (non-cuckoo) eggs out of the nest. If the other eggs hatched first, the babies are pushed out too. The host parents often continue to feed the cuckoo even after it grows to be much larger than they are, and cuckoo chicks sometimes use their call to lure other birds to feed them as well. Interestingly, only Old World (European) cuckoos colonize other nests. The New World (American) cuckoos build their own (untidy) nests. Like many Americans, these cuckoos migrate to the tropics for winter.
Cuckoos have a long and glorious history in literature and the arts. The Bible mentions them, as do Pliny and Aristotle. Beethoven used the cuckoo's distinctive call in his Pastoral Symphony. And here's a bit of etymology: the word "cuckold" (a husband whose wife is cheating on him) comes from "cuckoo." Presumably, the practice of laying one's eggs in another's nest seemed an appropriate metaphor.
Adam Witwer was the production editor and Chris Downey was the copyeditor for PHP in a Nutshell. Carol Marti proofread the text. Sanders Kleinfeld and Claire Cloutier provided quality control. Johnna VanHoose Dinse wrote the index. Karen Montgomery designed the cover of this book, based on a series design by Edie Freedman, and produced the cover layout with Adobe InDesign CS using Adobe's ITC Garamond font. The cover image is a 19th-century engraving from the Dover Pictorial Archive.
David Futato designed the interior layout. This book was converted by Judy Hoer 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 LucasFont's TheSans Mono Condensed. The illustrations that appear in the book were produced by Robert Romano, Jessamyn Read, and Lesley Borash using Macromedia FreeHand MX and Adobe Photoshop CS. The tip and warning icons were drawn by Christopher Bing. This colophon was written by Nathan Torkington and Rachel Wheeler.
