Your SlideShare is downloading. ×
Geek Austin PHP Class - Session 2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Geek Austin PHP Class - Session 2

507
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
507
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Beginning PHP Session #2 November 17, 2010 Josh Butts
  • 2. Agenda for Today • Go over Homework #1 • Include & Require • Errors &Warnings • String Functions • WritingYour Own Functions
  • 3. Corrections • Use “echo $foo”, not “echo($foo)” • I think we forgot to talk about code comments, so lets do that now
  • 4. Comments
  • 5. A note on constructs vs. functions • A language construct is a core part of the language, like “true”,“include” and “isset” • Some things in PHP behave like functions, but are actually language constructs
  • 6. String Functions • You’ll use these all the time • The internet deals in strings • Much like array functions, there are quite a few
  • 7. strlen() • How long is a string, in characters? • As long as this isn’t UTF-8-ish
  • 8. substr() • Get a smaller part of the whole string • Operates by “index”
  • 9. str_replace() • search and replace strings within strings • use arrays for extra power
  • 10. strpos() • Finds out the “index” location of a string within a string • Commonly used to find if a string exists within another
  • 11. Changing Case
  • 12. explode() • Split up a string on certain characters and give back an array of the pieces
  • 13. implode() • Build a string from an array
  • 14. Functions • Functions are ways to encapsulate & organize your code • Hundreds of built-in functions • Calculate values, perform repetitive tasks, output data
  • 15. WriteYour Own Functions
  • 16. Include • Load another PHP file into the current contexts • Executes that code as if it were in the current file • Gives a warning if the file is not found
  • 17. Include_Once • The same as include, except keeps track of if you’re already included the file and only includes it once • Use but don’t abuse, there is an implicit speed penalty for doing this
  • 18. Require • Functions the same way as include except gives a fatal error if the file is not found • Tends to be used for system components vs. small output snippets • Require_once == include_once