Objectives
  • Construct text strings
  • Work with single strings
  • Work with multiple strings and parse strings
  • Compare strings
  • Use regular expressions
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 3 - Manipulating Strings
Appendix C - Formatting Strings
Text Resources
     Errata Sheet
     Best Practices

Required and Recommended Tutorials
Required REGEX Video Series http://code.tutsplus.com/tutorials/regular-expressions-for-dummies-screencast-series--net-7887
(Also see materials under supplemental materials below)
  • Lesson 1: Introduction to REGEX (19:53 min - but worth it!):
  • Lesson 2: Matching (13:33 - shows how to implement in PHP, at about 10 minute mark switches to JavaScript so you can probably stop at that point) :
  • Lesson 3: Validating Email Addresses: (10:57 min)
Supplemental Video: Lynda.com: 
Sample Code
None this week
Supplemental Materials
Software

Same software as previously indicated with the following addition:

RegExr (REGEX Validator)

    • Online tool to learn, build and test Regular Expressions (Click on the tutorial link in the upper right to learn how to use the validator)
      http://regexr.com/

Chapter Questions and Test Reviews

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

Required Assignments

SSP04: String Functions (Complete, upload to Apollo1, then submit URL in the LMS)
Weekly Quiz: Chapter 3 (Located in the LMS)

Professor's Class Notes and Comments

Upon initial glance at the title of this week's chapter, one might think there is not going to be much to it this week. Please do not be fooled. Depending on your programming experience, be prepared to spend some quality and quantity time this week.

Perhaps the best way to begin is to read/work examples on pp.125-159 in the text. Along with this view the Lynda.com videos on strings and string functions. Also look under supplemental materials to see the professor's modification of the text's PowerPoint that accompanies the text.

Once you have a clear understanding of basic string functions, then progress to regular expressions (REGEX). I would probably recommend watching the three videos from the REGEX video series (perhaps fast forwarding as appropriate) and then read the text. When you have finished that, in the supplemental materials, there are some examples for you to work through using either the desktop or online software (located in the software tab) making sure you have a clear understanding of the topic (REGEX is not for sissies - so don't be fooled. With that being said, it is an extremely powerful tool!). Also, be sure to check out the REGEX cheat sheet.

Next, read Appendix C in the back of the text. The videos in the Beyond the Basics course should help with your understanding. Also check out the link to Php.net under the topic of sprintf().

Okay, now here are some more specific notes.

Strings

p. 126
There is a good chance you have already been introduced to this, but the concatenation operator in PHP is . (period) and the concatenation assignment operator is .= (period followed by equal sign). Example echo "This is " . $rating . "fun!";

p. 131-132
When using complex string syntax, note that there is no space between the curly braces and variable name. Also the $ which identifies a variable may be inside or outside of the curly braces.
Correct ${items} {$items}
Incorrect { $items}

p. 134
As you will soon discover PHP is a very function rich language. While these do make programming easier, it can be a bit of a challenge to remember all of them as well as their corresponding arguments.

p. 138
Hashes will be covered in more detail when Secure Coding is discussed.

Regular Expressions (REGEX)

    1. Again, please view the videos first. I really think that will help.
    2. Read the text p. 160-170
    3. Review addition resources as outlined on REGEX.htm
    4. Use the CheatSheet as needed
    5. On the REGEX.htm page, at minimum go through the examples typing them in and testing them yourself (REGEX Validator).
    6. Write the expressions for the nine(9) examples that follow the table on REGEX.htm
    7. This is definitely a topic that is mastered by actually creating and testing the code.
    8. On the test you will be required to create a Regular Expression so be sure you work through this material as suggested.

Formatting Strings

p. 641
The formatting options are the same for printf() which outputs a text string and sprintf() which returns a formatted value that that can be assigned to a variable are both the same. A separate set of syntax values are not needed for each. PHP.net has some excellent examples. Examples from PHP.net

Okay, that was a lot of material...but now on to the assignment. See the assignment specifications for details. Please keep in mind that even though a topic is not included in an assignment, students are still responsible for learning the material. More specifically, formatting strings and REGEX will definitely be on the test and may be included in future assignments.

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