• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Fall 2011 PHP Class - Session 2
 

Fall 2011 PHP Class - Session 2

on

  • 653 views

 

Statistics

Views

Total Views
653
Views on SlideShare
653
Embed Views
0

Actions

Likes
0
Downloads
5
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Fall 2011 PHP Class - Session 2 Fall 2011 PHP Class - Session 2 Presentation Transcript

  • Beginning PHP Session #2 October 6, 2011 Josh Butts
  • Agenda for TodayGo over Homework #1Control StructuresInclude & RequireString Functions
  • Control StructuresIf - Else statementsTernary OperatorSwitch StatementsLoops
  • If Statements
  • Switch Statements
  • 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
  • LoopsAnother core language function that is used repetitively (Ha!)Types For Foreach (remember this one) WhileLoops and arrays were meant for each other
  • For Loops
  • Foreach, the mightiest loop
  • While - The Boolean Loop
  • String FunctionsYou’ll use these all the timeThe internet deals in stringsMuch like array functions, there are quite a few
  • strlen() How long is a string, in characters?
  • substr() Get a smaller part of the whole string
  • str_replace() search and replace strings within strings use arrays for extra power
  • strpos() Finds out the “index” location of a string within a string Commonly used to find if a string exists within another
  • Changing Case
  • explode() Split up a string on certain characters and give back an array of the pieces
  • implode() Build a string from an array
  • 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
  • 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
  • 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