Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Fall 2011 PHP Class - Session 2

874 views

Published on

  • Be the first to comment

  • Be the first to like this

Fall 2011 PHP Class - Session 2

  1. 1. Beginning PHP Session #2 October 6, 2011 Josh Butts
  2. 2. Agenda for TodayGo over Homework #1Control StructuresInclude & RequireString Functions
  3. 3. Control StructuresIf - Else statementsTernary OperatorSwitch StatementsLoops
  4. 4. If Statements
  5. 5. Switch Statements
  6. 6. Ternary - A Special If-Else Shorthand for an IF statement with exactly one else condition Returns a value to a variable or function rather than running code Any single expression can be interchanged for any of the sections outlined below, including variables, functions, even another ternary
  7. 7. LoopsAnother core language function that is used repetitively (Ha!)Types For Foreach (remember this one) WhileLoops and arrays were meant for each other
  8. 8. For Loops
  9. 9. Foreach, the mightiest loop
  10. 10. While - The Boolean Loop
  11. 11. String FunctionsYou’ll use these all the timeThe internet deals in stringsMuch like array functions, there are quite a few
  12. 12. strlen() How long is a string, in characters?
  13. 13. substr() Get a smaller part of the whole string
  14. 14. str_replace() search and replace strings within strings use arrays for extra power
  15. 15. strpos() Finds out the “index” location of a string within a string Commonly used to find if a string exists within another
  16. 16. Changing Case
  17. 17. explode() Split up a string on certain characters and give back an array of the pieces
  18. 18. implode() Build a string from an array
  19. 19. IncludeLoad another PHP file into the current contextsExecutes that code as if it were in the current fileGives a warning if the file is not found
  20. 20. Include_OnceThe same as include, except keeps track of if you’re alreadyincluded the file and only includes it onceUse but don’t abuse, there is an implicit speed penalty fordoing this
  21. 21. RequireFunctions the same way as include except gives a fatal errorif the file is not foundTends to be used for system components vs. small outputsnippetsRequire_once == include_once

×