Chapter 7. Functions

This chapter examines how you define and use functions. It introduces the general concept of functions before discussing the specifics of how PHP functions work; it covers the following topics:

  • Defining functions

  • Understanding variable scope in functions

  • Managing function parameters

    • Parameters by value or reference

    • Parameter default values

    • Variable-length parameter lists

  • Using functions to return values

  • Managing dynamic function calls

  • Using recursive functions

All programs contain instructions to perform tasks. When sets of tasks are frequently used to perform an activity, they are grouped into units, which are known as functions or methods in most programming languages. PHP calls these units functions.

Functions should perform ...

Get Oracle Database 10g Express Edition PHP Web Programming 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.