I. What is a function and why do you use a function
A function is a code that is named to accomplish a particular task. function can save compilation time, no matter how many times it is called
Are compiled only once on the same page, and are easy to maintain, and also improve the readability of the code while maintaining ease of maintenance.
Two. Calling functions
1 $somevalue = function_name ([parameter, ...]);
Three. Defining functions
1 function [&] Function_name ([parameter[, ... ]]) {2list3 }
The statement can be HTML content, or even a function that does not include any PHP statement, and the function name can be a letter or an underscore beginning
Function names are case insensitive.
Four. Variable scope
Variables and parameters defined in the function cannot access external functions, and variables defined outside the function cannot access the contents of the function by default.
If you access a global variable in a function, you can use the Global keyword.
1 Global var1, VAR2, ...
PHP supports declaring that a function variable is static, and usually the first use of a static variable is to assign an initial value.
1 Static var [=value] [,...];
Five. Function parameters
A function can have any number of arguments, and there are two different ways to pass parameters.
The first is more commonly passed by value, and the second is reference passing.
PHP Function Learning Notes