Objectives
  • Use functions to organize your PHP code
  • Describe variable scope
  • Make decisions using if, if…else, and switch statements
  • Repeatedly execute code using while, do…while, for, and foreach statements
  • Utilize include and require statements
Assignments and Due Dates


Assignments and Due Dates: View
CS2623 Coding Standards - requirements for all class assignments

Required Readings

PHP Programming with MySQL //Second Edition by Don Gosselin, et al
Chapter 2 - Functions and Control Structures
Text Resources
     Errata Sheet
     Best Practices

Recommended Tutorials
Required Sample Code
The sample code is in a file which must be downloaded and extracted to location accessible by the server. Be sure to do this before testing the code.
Supplemental Materials

Chapter 2: PowerPoint from Text     View (.ppt) | Print (.pdf)

PHP.net - arguably. the definitive resource for all that is PHP.
Perhaps the easiest way to use it is to enter search criteria in the text box located in the upper right header area.

Software

Same software as previously indicated.

Chapter Questions and Test Reviews

Chapter 2: Review Questions (.rtf file)
Test 1: Review Sheet

Required Assignments

SSP03: Control Structures (Complete, upload to Apollo1, then submit URL in the LMS)
Weekly Quiz: Chapter 2 (Located in the LMS)

Professor's Class Notes and Comments

Since Beginning Programming (or another college-level programming class) is a prerequisite for this course, this week's chapter might seem a bit repetitious...and it might be for the majority of the class. However, this week's assignment is a bit involved. So it really could not be combined with next week's assignment which is also somewhat involved. Probably the newest concept, depending on if you have taken any 2000 level programming classes, is that of include files. They can be a powerful tool!

p. 78
Note that while variable and constants names are case sensitive, function names are not. However, it is recommended that student "pretend" that they are since this develops good programming practices and in other languages they are case sensitive.

p. 104
The Pointer (light bulb in left margin) states that portions of a for statement can be omitted. This can lead to confusion when maintaining code. In "this class" this technique is not allowed.

pp. 109-11, Include Files
The books coverage of this important topic is somewhat brief. The Lynda.com videos provide an excellent introduction. Other resources include

W3Schools

http://www.w3schools.com/php/php_includes.asp

PHP.net

http://php.net/manual/en/function.include.php
http://php.net/manual/en/function.include-once.php

http://php.net/manual/en/function.require.php
http://php.net/manual/en/function.require-once.php

Caveat: Include files will be displayed within other web pages. For that reason, do not add DTD information, <head>, <title>, <meta>, <body> and other similar tags. Doing so will cause duplication and errors when the server renders the web page.

In the Lynda.com videos, an especially important concept is covered in "Making sure internal links still work in an include file". When working locally (provided your configuration is as recommended in the setup instructions when you installed xAMP) the path (value for $siteRoot variable in the video) is as follows:

Viewing through Localhost

Replace FolderName with name of the folder in which you are currently working. Example: ChineseZodiac in this week's assignment.

$siteroot = 'ssp/FolderName';

The code for a an image or link would be similar to

<img src="<?php echo $siteroot; ?>/images/logo.png" alt="Some Image" height="100" width="200">

Viewing on the remote server - Apollo1

Replace user##### with your login and FolderName the name of folder in which you are currently working.

$siteroot = '/user#####/FolderName/';

The code for a an image or link would be the same as above

<img src="<?php echo $siteroot; ?>/images/logo.png" alt="Some Image" height="100" width="200">

 

Don't forget about the review questions and the weekly quiz in addition on to the Chinese Zodiac assignment.