PHP Back to Basics: Functions
In this tutorial, we're going to look at using functions in PHP. Functions allow you to lay out your code in a more organized way, and allow you to easily re use your code, saving you time, and making your projects easier to read and debug.
We’re going to look first at what functions are, and how they can be used. We then look at how to create a function in your code, and how to make the function accept arguments which can then be used in the function code. Next, we see how to return a value from a function to the calling code, so that the result can then be output or sent for further processing.
In the second part of this tutorial we look at the scope of variables, and how variables from your main code can be read or changed from within a function. Finally, we look at using the static command which can save the data held in variables between function calls.
Read More