PHP Functions

Example 1: Built-in Function

The length of my name is 16 characters.

Example 2: User-Defined Function

Hello, Nick!

Explanation

Functions are reusable blocks of code that perform a specific task. PHP has many built-in functions that programmers can use without creating them, such as strlen(), which finds the length of a string. A user-defined function is created by the programmer and can accept information called parameters. Functions help organize code and prevent the same code from being repeated.