Functions

In PHP, functions are blocks of reusable code that can be defined using built-in functions or created by the user. Here's an example using a built-in function and a user-defined function:

Built-in Function: The length of the string "Hello, World!" is obtained using the strlen() function. The result is 13.

User-defined Function: A function named greet() is created to generate a personalized greeting. The result of calling greet("John") is Hello, John!.

Functions in PHP help organize and modularize code. They can take parameters, perform tasks, and return values. This promotes code reuse and makes it easier to manage and understand complex programs.