Home  >  Article  >  What does function declaration mean?

What does function declaration mean?

藏色散人
藏色散人Original
2020-05-26 09:26:066737browse

What does function declaration mean?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn