PHP Functions

Example 1: Built-in PHP Function

Original text: Hello PHP
Number of characters: 9

Example 2: User-Defined Function

Hello Ward! Welcome to Activity 3.

Explanation

Functions are reusable blocks of code that perform specific tasks. PHP contains built-in functions, such as strlen(), which counts 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 whenever the function is called.


Back to Activity 3 Home Page