A function is essentially a section of code that you can call over and over again. This function can do repetitive tasks very easily and safely, and because it is encapsulated in a function name, it makes the main program look a lot neater.
We have been using a lot of predefined functions, written by PHP, such as strval() and nl2br(). Notice how both functions have parentheses after the name? That is a function’s defining attribute. In Chapter 6 I explain that I format my multi-word functions using an underscore. This is an example of one of my functions: