Pre-defined functions are already-implimented functions in PHP, echoing them will cause them to run and perform their pre-determined actions.
Below, the function phpversion() is echoed and prints out the current php version.
8.3.14
User-defined functions are created by the user, and perform the actions found within the function when called.
Functions are written out in the following format, function func_name(){ Within these brackets are intended actions }
Below a function named word_printer is called. It contains four echo actions that are executed each time it is called.
This is the first line of the function
This is the second line of the function
This is the third line of the function
This is the fourth line of the function
Functions are useful because they can be called and take up very little space inside of the code, making repeated actions very efficient, below I call the function 5 times, executing code that would originally take 20 lines to complete in a fourth of the effective space.
This is the first line of the function
This is the second line of the function
This is the third line of the function
This is the fourth line of the function
This is the first line of the function
This is the second line of the function
This is the third line of the function
This is the fourth line of the function
This is the first line of the function
This is the second line of the function
This is the third line of the function
This is the fourth line of the function
This is the first line of the function
This is the second line of the function
This is the third line of the function
This is the fourth line of the function
This is the first line of the function
This is the second line of the function
This is the third line of the function
This is the fourth line of the function