Length of the string: 13
Factorial of 5: 120
Functions in PHP allow you to encapsulate reusable code. The built-in strlen()
function calculates the length of a string. User-defined functions, like our factorial()
function, perform specific tasks. Functions improve code organization, readability, and maintainability.