A function is a reusable block of code that runs a specific task only when it is called. PHP already has many built-in functions, like strtoupper(), ready to use without setup. A user-defined function is one the programmer creates using the function keyword, giving it a name and any inputs it needs. Functions let code be reused just by calling the name instead of rewriting it.