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)

Date_Holidays


If you develop an application that needs to calculate holidays, PEAR::Date_Holidays is certainly a helpful solution. Its main job is calculating holidays (or other special days) and checking whether dates represent holidays. It hides the complexity of calculating non-static holidays like Easter or Whitsun. Additionally it allows for easy filtering of holidays and is I18N aware, in so far as it provides information about holidays in different languages.

Checking if your birthday in 2005 is a holiday is as easy as:

require_once 'Date/Holidays.php';
$driver = Date_Holidays::factory('Christian', 2005);
// actually this checks my date of birth ;-)
if($driver->isHoliday(new Date('2005-09-09')))
{
echo 'Oh happy day! Holiday and birthday all at once.';
} else {
echo 'Jay, it is my birthday.';
}

So, if you do not want to reinvent the wheel for a library calculating holidays that occur on different dates in different religions/countries, use Date_Holidays.

Before we start coding there...