Tracks
/
PHP
PHP
/
Syllabus
/
User Defined Functions
Us

User Defined Functions in PHP

0 exercises

About User Defined Functions

User-defined functions are created using the function keyword. It must then be followed by a function name and a list of arguments.

function alarm($hour, $minute, $second)
{
    return 'Alarm!';
}

Functions can be called in a file before they are defined, as they are hoisted to the top of their scope.

Naming

Function names in PHP follows the rules of other labels: It must begin with an underscore or letter, then may be followed by any number of letters, numbers, or underscores.

Edit via GitHub The link opens in a new window or tab