O'Reilly logo

Sams Teach Yourself PHP in 24 Hours, Third Edition by Matt Zandstra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

An Example

Let’s bring most of these functions together into an example. We are going to build a calendar that can display the dates for any month between 1980 and 2010. The user will be able to select both month and year with pull-down menus, and the dates for that month will be organized according to the days of the week. If the input is invalid or absent, we will default to the first day of the current month. To develop our calendar, we will create three classes.

The DateIterator Class

The DateIterator class in Listing 16.4 is responsible for setting a pointer to the beginning of the given month and counting each of its days.

Listing 16.4. The DateIterator Class
 1: <?php 2: class DateIterator { 3: public static $ADAY = 86400; 4: private ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required