PHP Functions

Example 1: Built-in PHP Function

Original text: Welcome to Activity 3

Number of characters: 21

Example 2: User-Defined Function

Hello, Charles! Welcome to INFOST 440.

Explanation

A function is a reusable block of code that performs a specific task. PHP has built-in functions, such as strlen(), that are already provided by the language. Programmers can also create their own functions for specific tasks. A user-defined function can receive information through parameters, process it, and return a result when the function is called.

Back to Activity 3 Home