CS 161 - Introduction to Programming with PHP

Lecture Notes: 27 Sept 2010
 

Topics that came up along the way...

  • Quoted strings and variables
  • Single- vs. double-quotes
  • Controlling rounding errors

Documenting your code

  • Various "styles" of comment syntax
  • State what you're doing, in prose
  • Don't restate what's obvious from the code, e.g. "Add 1 to $x"
  • Describe what blocks of code do; describe statements that aren't obvious
  • Be clear, complete, concise!

Arrays

  • General syntax
  • What can be used as index/keys?

Conditionals and Flow Controls (continued)

  • for (initializing-expr; conditional-expr; loop-expr) statement; // equivalent to:
    initializing-expr; while (conditional-expr) { statement; loop-expr; }
  • foreach (array_expression as $value) statement;
  • foreach (array_expression as $key => $value) statement;
  • break
  • switch
Page last updated 29 September 2010