Table Of Contentwww.it-ebooks.info
Summary of Contents: Volume I
Preface ........................................................................................................ ix
1. PHP Basics .............................................................................................. 1
2. Object Oriented PHP ............................................................................. 23
3. PHP and MySQL ................................................................................... 65
4. Files ..................................................................................................... 111
5. Text Manipulation ............................................................................... 143
6. Dates and Times .................................................................................. 171
7. Images ................................................................................................. 209
8. Email ................................................................................................... 237
9. Web Page Elements.............................................................................. 253
10. Error Handling ................................................................................... 319
A. PHP Configuration .............................................................................. 339
B. Hosting Provider Checklist................................................................... 347
C. Security Checklist ................................................................................ 351
D. Working with PEAR ............................................................................ 355
Index ....................................................................................................... 363
Summary of Contents: Volume II
Preface ...................................................................................................... xiii
1. Access Control ......................................................................................... 1
2. XML ...................................................................................................... 79
3. Alternative Content Types ................................................................... 169
4. Stats and Tracking ............................................................................... 221
5. Caching ............................................................................................... 241
6. Development Technique ...................................................................... 269
7. Design Patterns .................................................................................... 311
A. PHP Configuration .............................................................................. 355
B. Hosting Provider Checklist................................................................... 363
C. Security Checklist ................................................................................ 367
D. Working with PEAR ............................................................................ 371
Index ....................................................................................................... 379
www.it-ebooks.info
www.it-ebooks.info
The PHP Anthology
Volume I: Foundations
by Harry Fuecks
www.it-ebooks.info
The PHP Anthology, Volume I: Foundations
by Harry Fuecks
Copyright © 2003 SitePoint Pty. Ltd.
Editor: Georgina Laidlaw
Technical Editor: Kevin Yank
Cover Design: Julian Carroll
Printing History:
First Edition: December 2003
Notice of Rights
All rights reserved. No part of this book may be reproduced, stored in a retrieval system or transmitted
in any form or by any means, without the prior written permission of the publisher, except in the
case of brief quotations embodied in critical articles or reviews.
Notice of Liability
The author and publisher have made every effort to ensure the accuracy of the information herein.
However, the information contained in this book is sold without warranty, either express or implied.
Neither the authors and SitePoint Pty. Ltd., nor its dealers or distributors will be held liable for any
damages to be caused either directly or indirectly by the instructions contained in this book, or by
the software or hardware products described herein.
Trademark Notice
Rather than indicating every occurrence of a trademarked name as such, this book uses the names
only in an editorial fashion and to the benefit of the trademark owner with no intention of infringe-
ment of the trademark.
Published by SitePoint Pty. Ltd.
424 Smith Street Collingwood
VIC Australia 3066.
Web: www.sitepoint.com
Email: business@sitepoint.com
ISBN 0-9579218-5-3
Printed and bound in the United States of America
www.it-ebooks.info
About The Author
Harry is a technical writer, programmer, and system engineer. He has worked in
corporate IT since 1994, having completed a Bachelor’s degree in Physics. He
first came across PHP in 1999, while putting together a small Intranet. Today,
he’s the lead developer of a corporate Extranet, where PHP plays an important
role in delivering a unified platform for numerous back office systems.
In his off hours he writes technical articles for SitePoint and runs phpPatterns
(http://www.phppatterns.com/), a site exploring PHP application design.
Originally from the United Kingdom, he now lives in Switzerland. In May, Harry
became the proud father of a beautiful baby girl who keeps him busy all day (and
night!)
About SitePoint
SitePoint specializes in publishing fun, practical and easy-to-understand content
for Web Professionals. Visit http://www.sitepoint.com/ to access our books,
newsletters, articles and community forums.
www.it-ebooks.info
www.it-ebooks.info
For Natalie and Masha
www.it-ebooks.info
ii
www.it-ebooks.info
Table of Contents
Preface ..................................................................................................... ix
Who should read this book? ......................................................... x
What’s covered in this book? ........................................................ x
The Book’s Website ................................................................... xii
The Code Archive............................................................... xii
Updates and Errata ........................................................... xiii
The SitePoint Forums................................................................ xiii
The SitePoint Newsletters ......................................................... xiii
Your Feedback ........................................................................... xiv
Acknowledgements .................................................................... xiv
1. PHP Basics ............................................................................................. 1
Where do I get help? .................................................................... 2
Reading the Manual ............................................................. 2
Section I: Getting Started..................................................... 3
Section II: Language Reference ............................................. 3
Section III: Features ............................................................. 4
Section IV: Function Reference ............................................ 4
Further Help ........................................................................ 7
How do I fix an error that PHP finds in my script? ....................... 8
Syntax Errors ....................................................................... 9
Semantic Errors ................................................................. 10
Environment Errors ............................................................ 10
Logic Errors ....................................................................... 11
How do I include one PHP script in another? ............................. 12
Mutual Inclusion ............................................................... 12
Path Finding ...................................................................... 15
How do I write portable PHP code? ........................................... 16
Keep All Configuration Central .......................................... 17
Use the Full <?php ?> Tags............................................... 18
register_globals off ............................................................. 18
Magic Quotes .................................................................... 19
Call-Time Pass-By-Reference Off ........................................ 20
Write Reusable Code ......................................................... 20
Further Reading ......................................................................... 22
2. Object Oriented PHP ............................................................................ 23
What are the basics of object oriented PHP? .............................. 26
Classes and Objects ............................................................ 29
Understanding Scope ......................................................... 34
www.it-ebooks.info
Description:A compilation of best practice solutions to common Web Development problems in PHP, focusing on the achievement of practical goals by applying well-structured, object orientated software design principles. In addition to being an excellent reference with over 60 customizable solutions, the book acts