What does the declaration of a function mean?
"Function definition" refers to the establishment of function functions, including specifying function name, function value type, formal parameter type, function body, etc. It is a complete and independent function unit. The function of "function declaration" is to notify the compilation system of the function name, function type, formal parameter type, number and order, so that the system can check according to this when calling the function (for example, whether the function name is correct, the actual participation Whether the type and number of formal parameters are consistent).
In terms of writing form, the function declaration can copy the function header and add a semicolon at the end; and in the parameter list, you can only write the type name of each parameter instead of the parameter name.
Definition of function
The definition of function is a complete function unit:
Includes function type, function name, formal parameters and formal parameter types , function body, etc.
In the program, a function can only be defined once
There is no semicolon between the function header and the curly braces
Declaration of the function
The function declaration is just a description of the compilation system:
The function declaration is a type description of the return value of the defined function to inform the system that the function called in this function is what type.
Does not include the function body (or formal parameters)
After calling the function several times, a corresponding statement should be made in each calling function
The function declaration is a description statement. Must end with semicolon!
The above is the detailed content of What does function declaration mean?. For more information, please follow other related articles on the PHP Chinese website!