Functions in PHP

Built-in Function Example

Original text: hello world
Uppercase text: HELLO WORLD

User-defined Function Example

The sum of 5 and 7 is: 12

Explanation

In PHP, functions are blocks of code that can be reused many times. A built-in function is already made for you, like strtoupper() which changes text to uppercase. A user-defined function is one you create yourself, like addNumbers(), which adds two numbers together. Functions make code easier to read, reduce repetition, and allow you to organize your program into smaller, reusable parts.