O'Reilly logo

PHP for Teens by Maneesh Sethi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Functions

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:

execute_func();

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required