Hour 6. Functions

What You’ll Learn in This Hour:

  • How to define and call functions

  • How to pass values to functions and receive values in return

  • How to call a function dynamically using a string stored in a variable

  • How to access global variables from within a function

  • How to give a function a “memory”

  • How to pass data to functions by reference

  • How to create anonymous functions

  • How to check that a function exists before calling it

Functions are the heart of a well-organized script, making code easy to read and reuse. No large project would be manageable without them.

Throughout this hour, we will investigate functions and demonstrate some of the ways in which they can save you from repetitive work.

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.