Using a built in function

This built in function is used to count the length of a string:

The string "Count how many characters this string has!" has 42 characters!

Using a self-defined function

This self-defined function is used to check if the string has an even number of characters

Check if "Count how many characters this string has!" has an even amount of characters:
The string has an even number of characters

Check if "A string with uneven characters" has an even amount of characters:
The string has an odd number of characters

In PHP there are built-in functions like the one I used. They are already set by the language and can be used anytime without having to set it up.
But you can also write functions yourself to do various actions. With that you can write code that exactly fits your needs.
You often times use functions because you want to use the code more often and don't want to keep rewriting it.