PHP Function

In this chapter you will learn:

  1. What Is a Function?
  2. What is function parameter
  3. What is return value form a function
  4. Why Functions Are Useful

Description

A function is a self contained block of code that performs a specific task.

Parameter

A function often accepts one or more arguments, which are values passed to the function by the code that calls it.

The function can then read and work on those arguments.

Return

A function may optionally return a value that can then be read by the calling code.

In this way, the calling code can communicate with the function.

Why

Functions avoid duplicating code. They make it easier to eliminate errors.

Functions can be reused in other scripts. They help you break down a big project.

Next chapter...

What you will learn in the next chapter:

  1. How to create a PHP function
  2. Syntax to write your own functions
  3. Example - define a function
Home » PHP Tutorial » PHP Function Create
PHP Function
PHP Function Create
PHP Function Parameter
PHP Function Default Parameters
PHP Variable Length Parameter
PHP Function Reference Parameter
PHP Function Return
PHP Return Reference
PHP Variable Scope in Functions
PHP Global Variables
PHP Recursive Functions
PHP Anonymous Function
PHP static variable