PHP Functions

Built-in Function Example

The text is: Hello World
The length of the text is: 11

User-Defined Function Example

Hello, Sarah! Welcome to my PHP page.

Explanation

Functions are reusable sections of code that perform a specific task. PHP contains built-in functions such as strlen(), which counts the characters in a string. Programmers can also create their own functions. A user-defined function can accept information as parameters, perform instructions, and return a result when the function is called.

Back to Index