Skip to main content
Home
Completion requirements
Opened: Wednesday, 2 September 2015, 1:50 PM
Due: Friday, 11 September 2015, 1:50 PM

Lab 2: PHP

Learning Objectives

After completion of this lab, you should be able to

  • Work collaboratively as a pair programming team
  • Use PHP variables, arrays, and constants embedded inside html code Use PHP functions in a webpage
  • To Receive Credit

Work collaboratively as a pair programming team

In class, labs will be done using pair programming. You may wish to review basic pair programming guidelines before you begin.

  • One team member (the driver) has control of the keyboard/mouse and actively implements the program
  • The other team member (the navigator) continuously observes the work of the driver to identify tactical defects (such as syntactic and spelling errors, etc.) and thinks strategically about the direction of the work

You should change roles about every ten minutes during lab.

Use PHP variables, arrays, and constants embedded inside html code

Create a lab1.php file at D:\Stu_Name\PHP labs\lab1 with the following PHP constant and array variables

<?php
define ("DESIRED_LENGTH", 31);
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
$daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
?>

Use XHTML Strict and embedded PHP code to create the following page consisting of a heading 1 and a table

  • The table cells are dynamically created using PHP for loops and the PHP array variables given above The table's border is set to "1" and its cellpadding is set to "5" to make the cells stand out
  • The PHP string function strtoupper is used to convert the month names to upper case

  • Validate your page to XHTML 1.0 strict standards
  • Fix any accessibility issues reported by FAE Rule Set
    • Ignore the check: Most web pages should contain at least one navigation bar

Switch pair programming roles

Switch driver and navigator roles. You may be able to just slide the keyboard and mouse over, or it may be preferable to change seats. Do not change the computer in use.

Use PHP functions in an web page

Use HTML and PHP to add a paragraph under the table that displays the names of the months with the exact same number of days as defined by the constant DESIRED_LENGTH

  • Write a PHP function named getMonths that accepts 3 parameters: desiredLength, monthArray, and dayArray
    • Your function should use an if statement inside a loop to dynamically determine the months that match the desired length
    • Your functions should return the string containing a comma separated list of month names The ending comma may be removed from this string using the PHP rtrim function
  • Call your function from within the HTML code to provide the text for the paragraph
    • Ensure your output is correct when the DESIRED_LENGTH constant is changed to a different value (e.g. 30)

  • Validate your page to XHTML 1.0 strict standards
  • Fix any accessibility issues reported by FAE Rule Set
    • Ignore the check: Most web pages should contain at least one navigation bar

To Receive Credit

Pair programming teams will receive the scoring rubric sheet at the start of lab. Write both names on the sheet to turn in the sheet in when you finish. Name 1 should be the student who saved the pair work in their course account.

  • If you finish during lab, have your work checked for completeness, and turn in to your instructor the lab's scoring rubric [PDF].
    • If you have not yet satisfied all criteria to the level of 4, you need to continue working on the lab outside of class time
    • Your saved solution should be stored in the course account listed under Name 1
  • If you are unable to complete the solution during the lab period
    • Leave lab with both students having a copy of the partially completed solution
    • Agree to finish the lab together (establish a time) or independently
  • Turn in the lab's scoring rubric [PDF] at the start of next Lab
    • Use one rubric for teams finishing together or two rubrics for students finishing independently
    • Keep track of and include the total completion time (rounded to closest half­hour) it took to complete the lab assignment and include the time on the rubric
    • Write a score 0..4 in the rubric's self assessment column representing your completion status
  • Make sure your work is stored in your course account in folder D:\Stu_Name\PHPlabs\lab1\

Lab 1 is due at the start of the next lab. No late lab assignments will be accepted without prior approval. Your lowest lab score will be dropped.

loader image