PHP Functions

Built-in Function Example

The text is: Welcome to Activity 3

The strlen() function counts 21 characters.

User-Defined Function Example

Hello, Hemamrutha! Welcome to the PHP functions page.

Explanation

Functions are reusable blocks of code that perform specific tasks. A function can receive information through parameters, process that information, and return a result. PHP provides built-in functions such as strlen(), while programmers can create user-defined functions for their own tasks. Functions reduce repeated code and make programs easier to organize, read, test, and maintain.