Course Links

Assignments

Resources

External

The bulk of this assignment is designed to ensure that you get good practice working with arrays and PHP functions. A short section at the end asks you to envision a web site for later development when we begin to look at database operations.

Function and Array Exercises

Please complete the tasks outlined in the labs on arrays and on functions. When you have finished, there are a few more steps to clean up the script and make it easier to understand. Before doing these, you should make a new copy of the files in a directory for the homework (separate from your lab directory). The root of your student account should contain an index page with links to all lab work and homework, so that I can find it easily for grading purposes.

Here are the extra steps:

  1. Go back through the initial work from the arrays lab and identify places where you could replace a section of script with a call to one of your array_print functions. Make the appropriate replacement. At the end of this process, your script should have few if any loops left -- just a series of calls to different functions.
  2. It is customary to include a comment before each function definition describing what the function does and how it is to be used. These comments should pay special attention to describing the inputs and outputs to the function. For example, the function example introduced in class might be augmented with a simple comment as shown below.
  3. // Adds two numbers and returns the sum
    function myfun($arg1,$arg2) {
      return $arg1+$arg2;
    }
    
  4. Come up with one more function of your own design that will manipulate the arrays in the example in some new way. Try to pick something that is both useful and creative. Use your new function in at least two different ways. Include in the file at this point some text describing what your function does, and why you chose to develop it. Part of the grading on this section will be based on the appropriateness and creativity of your choice.

A Database Project

Next week we will start to look at databases. This topic will mean more to you if you have an application in mind that you can use to contextualize the techniques we will learn. For this portion of the homework, come up with a web site concept that you are interested in working on and that can support reasonably complex and varied forms of data. For example, an e-commerce site that keeps track of inventory, prices, and orders has sufficient complexity. A game site that merely keeps track of top scores does not, but adding additional information like player profiles and saved game information might suffice. You are not obligated to continue with this initial concept if you later come up with something you like better, but I want you to have something in mind to start. Describe your idea at the bottom of your homework page.