Book Image

PHP Programming with PEAR

By : Carsten Lucke, Stoyan Stefanov
Book Image

PHP Programming with PEAR

By: Carsten Lucke, Stoyan Stefanov

Overview of this book

<p>PEAR is the PHP Extension and Application Repository, and is a framework and distribution system for reusable, high-quality PHP components, available in the form of "packages". <br /><br />In this book, you will learn how to use a number of the most powerful PEAR packages available to boost your PHP development productivity. By focusing on these packages for key development activities, this book is an in-depth guide to getting the most from these powerful coding resources.<br /><br />You will become a master of various PEAR packages that help you with the essential tasks of PHP development such as:<br /><br />•&nbsp;&nbsp;&nbsp; Accessing databases with MDB2<br />•&nbsp;&nbsp;&nbsp; Displaying data in a range of formats (HTML, Excel spreadsheet, PDF)<br />•&nbsp;&nbsp;&nbsp; Creating and parsing XML documents<br />•&nbsp;&nbsp;&nbsp; Serializing PHP objects into XML, and unserializing XML documents to PHP objects<br />•&nbsp;&nbsp;&nbsp; Consuming and offering web services<br />•&nbsp;&nbsp;&nbsp; Accessing Web APIs including Google, Yahoo, Amazon, and Technorati</p>
Table of Contents (10 chapters)

Working with the Calendar Package


If you search for PHP-based calendar utilities on the Web you will find lots of solutions. Some are good, others are not. However, in most cases you will experience some constraints. Several libraries have month/day names hard-coded or are tied to a specific output format.

PEAR::Calendar helps you generate calendar structures without forcing you to generate a certain type of output or depending on a special data store as back end. It simplifies the task of generating tabular calendars and allows you to render whatever output you like (e.g. HTML, WML, ASCII).

The package provides classes representing all important date entities like year, month, week, day, hour, minute, and second. Each date class can build subordinated entities. For instance an object representing a month is able to build contained day objects. Try the following script to build and fetch objects for each day in December 2005:

// Switch to PEAR::Date engine
define('CALENDAR_ENGINE', 'PearDate...