This document summarizes the agenda and content covered in a PHP session on November 17, 2010. It discusses include and require functions, errors and warnings, string functions like strlen(), substr(), str_replace(), and strpos(), writing custom functions, and includes vs requires. Comments and a note on language constructs vs functions are also briefly covered.
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”
14. Functions
• Functions are ways to encapsulate &
organize your code
• Hundreds of built-in functions
• Calculate values, perform repetitive tasks,
output data
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