1234567

PHP is a simple yet powerful open source scripting language that has become a big player in web development. Over a million web sites, from large corporate sites to small personal sites, are using PHP to serve dynamic web content. PHP's broad feature set, approachable syntax, and support for different operating systems and web servers make it an ideal language for rapid web development.The PHP Cookbook is a collection of problems, solutions, and practical examples for PHP programmers. The book contains a unique and extensive collection of best practices for everyday PHP programming dilemmas. For every problem addressed in the book, there's a worked-out solution or "recipe" -- short, focused pieces of code that you can insert directly into your applications. But this book offers more than cut-and-paste code. You also get explanations of how and why the code works, so you can learn to adapt the problem-solving techniques to similar situations.The recipes in the PHP Cookbook range from simple tasks, such as sending a database query and fetching URLs, to entire programs that demonstrate complex tasks, such as printing HTML tables and generating bar charts. This book contains over 250 recipes on the following topics:

  • Working with basic data types, including strings, numbers, dates and times, and arrays
  • PHP building blocks, such as variables, functions, classes, and objects
  • Web programming, including forms, database access, and XML
  • Useful features like regular expressions, encryption and security, graphics, internationalization and localization, and Internet services
  • Working with files and directories
  • Command-line PHP and PHP-GTK
  • PEAR, the PHP Extension and Application Repository

This book contains an impressive collection of useful code for PHP programmers, from novices to advanced practitioners. Instead of poking around mailing lists, online documentation, and other sources, you can rely on the PHP Cookbook to provide quick solutions to common problems, so you can spend your time on those out-of-the-ordinary problems specific to your application.

David Sklar

David Sklar is a Distinguished Engineer at Ning, part of Glam Media. Inaddition to PHP Cookbook, he is the author of Learning PHP 5 (O'Reilly), and Essential PHP Tools (Apress), and a scintillating blog:http://www.sklar.com/blog/. David lives in New York City and has adegree in Computer Science from Yale University.

Adam Trachtenberg

Adam Trachtenberg is the Director of Platform and Services for eBay and is the author of two O'Reilly books, Upgrading to PHP 5 and PHP Cookbook.

Adam has an MBA from Columbia Business School. While there, he focused on general management and operations, with an emphasis on the field of technology. Adam also has a BA from Columbia University. As an undergraduate he majored in mathematics, and his other studies included computer science and Chinese.

  • Preface
  • Chapter 1: Strings
  • Chapter 2: Numbers
  • Chapter 3: Dates and Times
  • Chapter 4: Arrays
  • Chapter 5: Variables
  • Chapter 6: Functions
  • Chapter 7: Classes and Objects
  • Chapter 8: Web Basics
  • Chapter 9: Forms
  • Chapter 10: Database Access
  • Chapter 11: Web Automation
  • Chapter 12: XML
  • Chapter 13: Regular Expressions
  • Chapter 14: Encryption and Security
  • Chapter 15: Graphics
  • Chapter 16: Internationalization and Localization
  • Chapter 17: Internet Services
  • Chapter 18: Files
  • Chapter 19: Directories
  • Chapter 20: Client-Side PHP
  • Chapter 21: PEAR
  • Colophon