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

Dissecting a Function

Functions have three parts that we need to go over:

  • Function code

  • Parameter list

  • Return value

Only the code section is required; both the parameter list and the return value are optional. However, in most functions, you will be using all three.

Function Code

The function code section is the main section located between the curly braces: { and }. This section deals with the function’s actual work. You can add statements and expressions in this section as you would in a normal section of the code. Often, this section of the code interacts with the parameter list in the function declaration.

Parameter List

Parameters are variables and values that you can pass to a function when calling it. Remember when we used the nl2br() ...

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