Để xem đầu ra của phương pháp buildCalendar (), bạn sẽ cần phải sửa đổi trong thư mục công cộng để gọi phương thức. Cập nhật các tập tin với mã được in đậm: buildCalendar (); Kéo lên tập tin trong trình duyệt của bạn để xem? kết quả cho đến nay | CHAPTER 4 BUILD AN EVENTS CALENDAR Return the markup for output return html Modifying the Index File To see the output of the buildCalendar method you ll need to modify in the public folder to call the method. Update the file with the code shown in bold php Include necessary files include_once . sys core Load the calendar for January cal new Calendar dbo 2010-01-01 12 00 00 Display the calendar HTML echo cal- buildCalendar Pull up the file in your browser to see the results so far see Figure 4-4 . From library of Wow eBook 145 CHAPTER 4 BUILD AN EVENTS CALENDAR Figure 4-4. The heading and weekday abbreviations Building the Calendar The next step is to build the actual calendar days. Several steps need to be completed for this to work out 1. Create a new unordered list. 2. Set up a loop with an iteration counter a calendar date counter today s date and the month and year stored as variables that runs as long as the calendar date counter is less than the number of days in the month. 3. Add a fill class to the days of the week that occur before the first. 4. Add a today class if the current date is contained within the same month and year and matches the date being generated. 5. Create an opening and closing list item tag for each day. 6. Check if the current calendar box falls within the current month and add the date if so. 7. Check if the current calendar box is a Saturday and close the list and open a new one if so. 8. Assemble the pieces of the list item and append them to the markup. 146 CHAPTER 4 BUILD AN EVENTS CALENDAR 9. After the loop run another loop to add filler days until the calendar week is completed. 10. Close the final unordered list and return the markup. To start complete steps 1 and 2 by adding the following bold code to the buildCalendar method public function buildCalendar Determine the calendar month and create an array of weekday abbreviations to label the calendar columns cal_month date F Y strtotime .