PHP has a set of built-in functions.

Custom functions

You can — and should — also write your own custom functions.

Functions provide a system for organizing your code. A function is a container for some code, which will be available for use by other code.

Functions make code modular: easier to understand, more useful, more reusable.

A custom function begins with a name you invent for your function. Pick function names that are description The name must not be a PHP reserved keyword.


function functionName()
  code to be executed;

PHP function guidelines:

  • Give the function a name that reflects what the function does
  • The function name can start with a letter or underscore (not a number)

See Also